vector iterators

Aug 29, 2010 at 2:26am
If I have a vector
 
vector<int> incoming;

and I create an iterator
 
vector<int>::iterator in_it;

and set
1
2
 
in_it = incoming.begin();

and then erase the first member of the vector
 
incoming.erase(incoming.begin());

will the iterator now be automatically adjusted to the next member of the vector?
Aug 29, 2010 at 2:34am
no. Your iterator would become invalid.
Aug 29, 2010 at 4:34am
However, this would do the job:

in_it=incoming.erase(incoming.begin());

See why here -> http://cplusplus.com/reference/stl/vector/erase/ (see 'Return value')

Topic archived. No new replies allowed.