I am new to the C++ language. I have been starting to use vectors, and have noticed that in all of the code I see to iterate though a vector via indices, the first parameter
There's a couple of strong reasons to use iterators, some of which are mentioned here:
i.e., if you go from a std::vector to a std::list, or std::set, you can't use numerical indices to get at your contained value. Using an iterator is still valid.
If you modify your container in the middle of your loop, the next time you use your iterator it will throw an invalid iterator exception.