Created
December 6, 2014 22:27
-
-
Save mandyedi/75680876bb6a7865188d to your computer and use it in GitHub Desktop.
C++: std::vector: remove multiple element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::vector<Enemy*>::iterator itEnemy; | |
for ( itEnemy = v.begin(); itEnemy != v.end(); ) | |
{ | |
if ( (*itEnemy)->GetLife() <= 0 ) | |
{ | |
delete *itEnemy; | |
itEnemy = v.erase( itEnemy ); | |
} | |
else | |
{ | |
++itEnemy; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment