Iterators in C++
class some_iterator
{
Thing& operator*() const;
Thing* operator->() const;
const iterator& operator++();
const iterator& operator++(int);
bool operator==(const some_iterator& rhs) const;
bool operator!=(const some_iterator& rhs) const;
}
There's no base class for a C++ iterator because all the library uses are generic/templated. For what C++ library mavens call a forward iterator you needs to be dereferenceable (operator* and/or operator->), and support an increment. Depending on what you're doing, you'll need operator== and/or operator!=. You might need copy constructors and/or assignment operator. A thing that can be iterated just needs to provide begin() and end().
These are the first iterators we've seen so far that can be copied. They're also the only ones we've seen that can delimit subranges. C++ is also the only language we've looked at that has the idea (the concept) of output iterator (ie iterators that can only be written), reverse iterators, bidirectional iterators, etc. They're all top, in their place, but unfortunately not germane to the rest of the talk.