Which of the following is /are a valid iterator type?

Options
- Input Iterator
- Backward Iterator
- Forward Iterator
- Both a and c above


CORRECT ANSWER : Both a and c above

Discussion Board
About Iterator Valid type

Option both a and c is correct..
Iterators are classified into five categories depending on the functionality they implement:
1)Input 2)Output 3)Forward 4)Bidirectional 5)Random Access
Input and output iterators are the most limited types of iterators: they can perform sequential single-pass input or output operations.

Forward iterators have all the functionality of input iterators and -if they are not constant iterators- also the functionality of output iterators, although they are limited to one direction in which to iterate through a range (forward). All standard containers support at least forward iterator types.

Bidirectional iterators are like forward iterators but can also be iterated through backwards.

Random-access iterators implement all the functionality of bidirectional iterators, and also have the ability to access ranges non-sequentially: distant elements can be accessed directly by applying an offset value to an iterator without iterating through all the elements in between. These iterators have a similar functionality to standard pointers (pointers are iterators of this category).

Mayur Gaikwad 07-2-2016 11:02 AM

five types of iterators

iterators are classified into five categories depending on the functionality they implement:

Input
Output
Forward
Bidirectional
Random Access


Y.C. 09-9-2015 09:55 PM

c++

nice

manish singj 09-1-2015 08:52 AM

Backward iterator is also a correct answer, question is a confusing game with words

Backward iterator is also valid. If you say that backward and reverse are not the same thing then it's just a play with words and it means that the question is at least confusing.

For example the:
std::vector::rbegin
Return reverse iterator to reverse beginning
Returns a reverse iterator pointing to the last element in the vector (i.e., its reverse beginning).

Reverse iterators iterate backwards: increasing them moves them towards the beginning of the container.

stefan 05-30-2014 06:09 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement