How are iterators and pointers related?

Iterators are a generalization of pointers.

An iterator (depending on the variants) have to implement * and ++

So a pointer IS an iterator. But not necessarily the other way round.

If you want to iterate over a complex structure (a tree, a graph…), the iterator will be much more than a pointer, and doesn’t make any reference to some actual place in the ram.

Leave a Comment