|
-
February 27th, 2009, 09:33 AM
#5
Re: removing an element from a vector?
when will this code not work then? I guess what you mean is that i will actually change right?
say I have these elements in the list: a a b c d
and I do an erase on b, which is index i=2 my code would look like this:
vec.erase(vec.begin()+i);
however, in my for loop if it continues it will next grab index=3 which is now d, skipping the element c.
Is that a correct analysis?
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|