Chapter 24. Implementing Dynamic Storage in C++

  • Understand the benefits of container classes

  • Learn about dynamic arrays

  • Create a dynamic array class

  • Learn about linked lists

  • Create a linked list class


Container Classes

What do barrels, gas tanks, grocery bags, and milk cartons have in common? They’re all containers, and people use containers to store things. When you design a program, it’s often convenient to store similar data in containers of some sort. C++ classes are a great way to create dynamic containers that hold collections of objects while automatically handling memory management.

One common type of container is an array, a built-in feature of C++ you learned about in Chapter 6, “Using Arrays.” Another common type of container ...

Get Practical C++ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.