Introduction to OOP Chapter 19: Container Classes : next previous audio real text

Iterators and Encapsulation

Note that the iterator must almost always have detailed knowledge of the internal data structure. Wasn't our goal to hide these details?

Not exactly. The iterator is usually developed by the same programmer creating the data structure. It can share detailed knowledge with the data structure. And using the iterator does not require any knowledge of how the iterator is implemented.

Often friends (in C++) or nested classes (in Java) can be used to help the iterator share information with the container.

Intro OOP, Chapter 19, Slide 17