Why are there Vector Iterators??

I can see the point in map iterators and they make perfect sense, but vector iterators?? What is the point in a vector iterator? They don't make sense to me for this reason. Would someone explain please?
They let vector share a common interface with other containers. You can use begin()/end() in loops for any STL container, so changing between them is easy (if you decide you would like to use a different one later)

They also provide a way to access elements in a single type without directly accessing the container object itself. That is... if you have an iterator, you can access the data. But if all you have is an index, you can't (you need an index and the container itself)
Adding to what Disch has already said about the common interface, the STL algorithm library functions will take iterators as parameters so the std::sort() algorithm will work on a any container as will the std::find(), std::copy() etc..
Topic archived. No new replies allowed.