7. Iterators
On the one hand iterators are generalisations of pointers which represents positions in a container. On the other hand, they provide powerful iteration and random access in a container.
Iterators are the glue between the generic containers and the generic algorithms of the Standard Template Library.
Iterators support the following operations:
- *
- Returns the element at the current position.
- ==, !=
- Compares two positions.
- =
- Assigns a new value to an iterator.
The range-based for-loop uses the iterators implicitly.
Because iterators are not checked, they have the same issues as pointers.