2. The C++ iterator

2.1. Starting and Ending Positions
2.2. Names for iterator types
2.3. Adding an Iterator to the Book Interface
2.4. Iterators as Search Results
2.5. Implementing the Iterator
2.6. But it's so ugly!
2.7. Some Iterators are Easy
2.8. Variations

This problem of dealing with positions is so common that a specific C++ style has evolved to deal with it. In C++, we call these position ADTs iterators.

The interface to a C++ iterator is shown here.

iterator it;
get the data at a position *it
it->foo()
advance to the next position ++it or it++
compare two positions it == it2
it != it2

In the Forum:

(no threads at this time)