Iteration and Iterators

One final topic before we leave our discussion of container classes is a nod to an idea we will explore in more detail in the next chapter.

A common problem in container classes is how to provide access to the elements of the container without explosing the internal implementation details. A solution that has lately become popular in many object-oriented languages is the idea of an iterator. An iterator is a facilitator class that is used simply as a means for getting hold of values. In C++, since operators can be overloaded, we can even make an iterator look very much like a pointer. We will have more to say about this in the next chapter.

[audio] [real] Text to accompany slide18, in Chapter 15 of An Introduction to Object-Oriented Programming