By using an iterator one is isolated from these sorts of consequences.
An actual iterator object may exist in reality, but if it does it is not exposed within the source code of the language.
In procedural languages it is common to use indexing based on a loop counter to loop through all the elements in a sequence such as an array.
Although indexing may also be used with some object-oriented containers, the use of iterators may have some advantages: The ability of a container to be modified while iterating through its elements has become necessary in modern object-oriented programming, where the interrelationships between objects and the effects of operations may not be obvious.
A nice property of a C Standard Template Library (STL) map, multimap, set or multiset is that you can insert or erase elements without invalidating existing iterators.
This is especially useful if you are looping through a container and in the loop body decide if you want to erase the element currently processed.