Getting a General Bidirectional Iterator from a Vector

Before writing a function that accepts a general bidirectional iterator, I would like to check how this works for the vector ints.

vector<int> a(10,1);
iterator<bidirectional_iterator_tag, int> i = a.begin();
for (; i != a.end(); ++i) cout << *i;

This code does not compile. g ++ complains that you can not convert the return type of the begin () in iterator<bidirectional_iterator_tag, int>, and that operators ++and *it is not defined. Obviously, I am doing something wrong, I will be grateful for the help.

+5
source share
1 answer

std::iterator , , , . , . , . vector<int>::iterator . , ++ 11, auto, .

+6

All Articles