Introduction to OOP: Chapter 15 : Case Study: Container Classes [next] [previous] [audio] [real] [text]

Iteration and Iterators

Want a mechanism that allows iteration over containers of values without exposing inner working.

Can be performed using an iterator. In C++ can be made to look like a pointer.

list::iterator start = aList.begin();
list::iterator end = aList.end();

for ( ; start != end; ++start)
	cout << (*start) << endl;
Intro OOP, Chapter 15, Slide 18