chapter  8
30 Pages


In this chapter we explore a variety of container classes available in C++. The C++ arrays provide little functionality and can be difficult to use. It is easy to make mistakes using arrays: the arrays might not be big enough to hold the data, we might access elements beyond the end of the array, there is no convenient way to enlarge an array after it has been created, and it is easy to forget a delete[] statement for an array that has been dynamically allocated. In lieu of holding values in arrays, C++ provides the means to create arraylike

structures that can change size on demand, unordered collections (sets and multisets), and other useful containers (stacks, queues, double-ended queues, and simple lists). These containers are easy to use.