+ 1
How to use erase w/ C++'s vectors
I have a "struct tir int x,y struct alien int x,y" And i made vectors of tirs and aliens but i dint now what to write in aliens.erase(????) to remove a specific one, can you help me?
5 Réponses
+ 4
~ swim ~
Small correction, since the vec.erase returns the next valid iterator, you probably don't want to increment it again with the ++it when you reach the end of the body.
Erasing the last element in this case would crash the program.
Probably want to move the ++it to an else block.
+ 4
~ swim ~ Can't blame you there, this happens to me pretty much every time as well. :)
+ 1
It's at line 86
+ 1
I dont understand, can you fill?
for(tir& t : tirs)
for(alien& a : aliens)
if(t.x>a.x && t.x<a.x+60 && t.y>a.y && t.y<a.y+60)
"Erase the aliens shots"