×

Loading...

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

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++;

}
Report