I have a vector that stores pointers to many objects instantiated dynamically, and I\'m trying to iterate through the vector and remove certain elements (remove from vector
You need to be careful because erase() will invalidate existing iterators. However, it will return a new valid iterator you can use:
for ( it = Entities.begin(); it != Entities.end(); ) { if( (*it)->getXPos() > 1.5f ) { delete * it; it = Entities.erase(it); } else { ++it; } }