Which is the following is syntactically correct for vector v?

a) vector <int> :: const_iterator itr = v.rbegin();
b) vector <int> :: reverse_iterator itr = v.begin();
c) vector <int> :: iterator itr = v.begin();
d) vector <int> :: iterator itr = v.cbegin();

1 thought on “Which is the following is syntactically correct for vector<int> v?”

  1. c
    Explanation: v.rbegin() returns itertor of reverse iterator therefore cannot be stored in const_iterator(type mismatch). Similarly v.begin() returns normal iterator therefore cannot be stored in reverse_iterator and v.cbegin() returns the const_iterator therefore cannot be stored in normal iterator.

Leave a Comment