Now consider the memory consumed by the old and new versions of the volume-computing programs. The old version, using an array of 100 cylinderseach of which consumes, say, 16 bytesuses 1600 bytes, no matter how many cylinders are read from a file. The new version, using an array of 100 pointerseach of which consumes, say, 4 bytesuses 400 bytes for pointers plus 16 bytes for each cylinder read from a file.
If 100 cylinders are read from a filethe worst casethe total memory consumed by the new version, the one that uses pointers, is 2000 bytes, which is more than the 1600 required by the old version. On the other hand, if only 10 cylinders are read, the total memory consumed by the new version is only 400 + 10 * 16 = 560, which is much less than the 1600 required by the old version. Thus, you can save a great deal of memory if the expected number of class objects is much less than the worst-case number of class objects you need. Your saving increases as the size of each class object grows relative to the size of each pointer.