In programming, an iterator identifies an element in a container, akin to a pointer. We can use the same access syntax as pointers depending on what data structure we’re using; i.e., dereference, arithmetic.
The idea is we should be using something other than operator[]
to access elements. Note that for a container s
, the method s.begin()
points to the first element, and s.end()
points to the position after the last element.