I've looked this up already and here (http://stackoverflow.com/questions/4645705/vector-erase-iterator) the answer is as such:
t the end of the loop ++iterator is always called, so you increment .end() which is not allowed.
Simply checking for .end() still leaves a bug though, as you always skip an element on every iteration (it gets 'incremented' by the return from .erase(), and then again by the loop)
So can someone explain why doing it this way is wrong?
vector<AnimatedBitmap*>::iterator thisIter;
for (thisIter = allLoaded.begin(); thisIter < allLoaded.end(); thisIter++)
{
if ((*thisIter)->GetID() == this->mID)
thisIter = allLoaded.erase(thisIter);
if (thisIter == allLoaded.end())
break;
}
I don't see how we're skipping an element.