Could someone please explain iterators to me? They are mentioned in the C++ strings tutorial, however I honestly just don't understand them at all.
The part that they are mentioned at are as follows:
"On the other hand, strings are actually sequences, just like any other STL container, so you can use iterators to iterate over the contents of a string.
Note that my_string.end() is beyond the end of the string, so we don't want to print it, whereas my_string.begin() is at the first character of the string.Code:
for(my_iter = my_string.begin(); my_iter != my_string.end(); my_iter++)
Incidentally, C++ string iterators are easily invalidated by operations that change the string, so be wary of using them after calling any string function that may modify the string."