When more specialized functions are necessary, more specialized iterators may be provided.As a concrete example, think of a pointer that is pointing to the first element of an array (which is a container) and is iterated by the operator successively, pointing to all elements in the array until it reaches the end of it.It doesn't even have to be derived from some base iterator class (actually, there is no such a thing, just like there is no such a thing as a Container class from which all container classes are derived.
The problem is how to have an interface to all containers that is shared by all of them so that their commonality is fully explored but at the same time leaves room for their different strengths to be used.
The differences have to be explored by differentiated interfaces, but having a common interface is important if we want to write algorithms that can be applied to any containers through templates. It is useful to think of an iterator as a pointer, initially, even though iterators are a more complex generalization of the idea of a pointer.
It is also possible to remove any element from it, but this is expensive compared to the same operations in other containers that however don't allow finding an element by its position.
This means that you have to know the weaknesses and strengths of each container to know which one to use in a certain task.
In particular, any kind of iterator in this hierarchy also belongs to all kinds to the left.
Therefore, Input and Output iterators are the simplest and less specialized iterators, and Random access iterators are the most complex and specialized iterators.(This may be a little confusing specially for the string header files: string.h is the old C strings header files, string is the new C Standard Library string class, and cstring is the old C string library in the std namespace.)Container types, iterators and generic algorithms are what was known before as the Standard Template Library, created by Alexander Stepanov. The name STL is still useful to refer to this specific part.There is a huge number of functions, classes and methods in STL.The iterator will be referencing each element of the container successively.Many algorithms, like copying a container, may be expressed using only that.They will save you a lot of programming by allowing you to express complex containment ideas very directly.