What are Iterators in C++ and Object Oriented Programming ? Explain where we use them
![]() Don't want to miss a single bit? Subscribe By Email for Daily Jobs |
Iterators allow the traversal of a container object. They provide a generic interface to navigate a container without having to know the actual type of its elements. Several member functions of containers like begin () and end () return a pointer to iterators. Begin () returns a pointer to the beginning of a container and end returns a pointer one position past the last valid element of a container. This element past the last element marks the end of the container like a \0 is used to mark the end of strings.
The functions begin () and end () come in two flavors: const and non const. The non cons version returns non const iterator that enables a user to modify the value of its container while const iterators cannot modify its container.
e.g. vector
vector
Related Articles
- What are Vectors in C++(Object Oriented Programming) and how are they used ?
- What are containers in C++ and in Object Oriented Programming ? Which objects are available as containers ?
- What are collection objects in VB.net ?
- What is a Copy Constructor in C++ ? Give an example
- What are the difference between Set and List.in Java ?


