Search
 
SCRIPT & CODE EXAMPLE
 

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;
 }
Comment

PREVIOUS NEXT
Code Example
Cpp :: number of words in c++ files 
Cpp :: print all elements of vector c++ 
Cpp :: C++ Swap 2 Variables Without Using 3rd Variable 
Cpp :: delete one specific character in string C++ 
Cpp :: Write C++ program to sort an array in ascending order 
Cpp :: min heap and max heap using priority queue 
Cpp :: vector.find() 
Cpp :: all data types in c++ 
Cpp :: c++ prime sieve 
Cpp :: not in c++ 
Cpp :: read comma separated text file in c++ 
Cpp :: minimum value in array using c++ 
Cpp :: restting a queue stl 
Cpp :: c++ read each char of string 
Cpp :: index string c++ 
Cpp :: swapping of two numbers 
Cpp :: c++ splitstring example 
Cpp :: c++ fstream 
Cpp :: function c++ 
Cpp :: Accpt array input in single line in cpp 
Cpp :: c++ modulo positive 
Cpp :: How to create files in C++ 
Cpp :: cpp absolute value 
Cpp :: how to add external library in clion 
Cpp :: Find minimum maximum element CPP 
Cpp :: c preprocessor operations 
Cpp :: opengl draw semi circle c++ 
Cpp :: login system with c++ 
Cpp :: check if a key is in map c++ 
Cpp :: c++ program to convert character to ascii 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =