Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ vector loop delete

for (vector<Player>::iterator it=allPlayers.begin(); 
                              it!=allPlayers.end(); 
                              /*it++*/) <----------- I commented it.
{

   if(it->getpMoney()<=0) 
      it = allPlayers.erase(it);
  else 
      ++it;
 }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #vector #loop #delete
ADD COMMENT
Topic
Name
5+9 =