if alterator points to the last element, aVector.erase(aIterator ) will return end().

jfhuang (Zigzag)
So you have to check if alterator is at the end. Otherwise you will get an error. The modified code is as follows,

for (aIterator = aVector.begin();aIterator != aVector.end())
if (aVector.get(aIterator )==0)
aIterator =aVector.erase(aIterator );
if (aIterator != aVector.end()) alterator++;

2001-7-23 -04:00
This post has been archived. It cannot be replied.
Page address has been copied. To share, click to copy page address.
Share Online by QR Code

Back To Topic: (C++)How to get object from vector one by one in a loop? thanks. After I erase an element from a list,where the pointer will point to?

Back To Forum: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论