A Word About Memory

When you declare an array, you tell the compiler exactly how many objects you expect to store in it. The compiler sets aside memory for all the objects, even if you never need to use it. This isn't a problem with arrays for which you can estimate how many objects you'll need. For example, a chessboard has 64 squares, and CATs generally have between 1 and 10 kittens. When you have no idea of how many objects you'll need, however, you must use more advanced data structures.

This book looks at arrays of pointers, arrays built on the heap, and various other collections. More advanced data structures that solve large data-storage problems are beyond the scope of this book. Two great things about programming are that there are always ...

Get Sams Teach Yourself C++ in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.