Among the most popular types of classes are container classes (also called collection classes), i.e., classes designed to hold collections of objects. Container classes commonly provide services such as insertion, deletion, searching, sorting, and testing an item to determine whether it is a member of the collection. Arrays, stacks, queues, trees and linked lists are examples of container classes; we studied arrays in Chapter 7 and will study each of these other data structures in Chapter 21, Data Structures, and Chapter 23, Standard Template Library (STL).
It is common to associate iterator objectsor more simply iteratorswith container classes. An iterator is an object that "walks through" a collection, returning the next item (or performing some action on the next item). Once an iterator for a class has been written, obtaining the next element from the class can be expressed simply. Just as a book being shared by several people could have several bookmarks in it at once, a container class can have several iterators operating on it at once. Each iterator maintains its own "position" information. We will discuss containers and iterators in detail in Chapter 23.