C++ Iterator class - Define an Iterator class in C++

Define an Iterator class.

An iterator class is used to iterate through objects of the container class. An iterator is an entity that gives access to the contents of a container object.

Define an Iterator class.

- A container class hold group of objects and iterator class is used to traverse through the objects maintained by a container class. The iterator class provides access to the classes inside a container. They are objects that point to other objects. Iterator points to one element in a range, and then it is possible to increment it so that it points to the next element.
- There are several different types of iterators :

1. input_iterator
2. output_iterator
3. forward_iterator
4. bidirectional_iterator
5. random_iterator
6. reverse_iterator

Explain different types of iterators, i.e. input_iterator, output_iterator etc.

Input Iterator :
These iterators can read values in the forward movement. They can be incremented, compared and dereferenced.

Ouptut Iterator :
They write values in the forward movement. They can be incremented and dereferenced.

Forward Iterator :
They are like input and output iterators that can read and write values in forward movement.

Bidirectional Iterators :
These can Read and write values with forward and backward movement and can be incremented, decremented.

Random Access Iterator :
Can read and write values randomly.

C++ pure virtual functions related interiew questions and answers
C++ pure virtual functions - What are pure virtual functions?, What is a virtual base class?, What are virtual functions?
ATL Server interview questions and answers - ATL Server FAQ
What is Swing?, What is AWT?, What are the differences between Swing and AWT?, What are heavyweight components? What is lightweight component?
C++ Syntax questions
Questions on C++ Syntax - What are the Sizes and ranges of the Basic C++ data types?, What are the new features that ISO/ANSI C++ has added to original C++ specifications? etc.
Post your comment