Home Segments Index Top Previous Next

Chapter 28:

How To Store Pointers to Class Objects

Frequently, it is difficult to predict exactly how many data you will encounter at run time. Hence, you may find yourself creating ridiculously large global arrays just to be sure that you do not run out of space. Such arrays can waste a lot of memory, particularly if they hold large class objects.

Fortunately, you now know that you can arrange for the C++ compiler to allocate only pointers at compile time, deferring the allocation of memory for objects until run time.

In this chapter, you learn that arrays of pointers waste much less space on excess array capacity than arrays of objects do.