PDA

View Full Version : ::iterator



mickey
17th March 2006, 17:59
Hello,
I have a prob.


vector<Some> some(10);
vector<Some>::iterator ii;
vector<Some>::iterator cc;

assuming that ii is at the last element of some I need to do:


cc=ii+1 //I'm out
if (cc <= some.size()) ....

In other words i need to know when ii+1 is an iterator more large of 10 (number of elements of verctor)
Thanks

jacek
17th March 2006, 18:17
vector<...>::end() points behind last element.


for( vector<int>::iterator i = v.begin(); i != v.end(); ++i ) {
// ...
}

brcain
20th March 2006, 22:05
Try this ...


cc = ++ii;
if(cc != some.end())
...