How to delete element from Vector:
There is tricky thing for deleting in vector loop.
The erase method returns the next element after the one you just erased. So you can use that to continue in your loop.
vector c;
iterator i = c.begin();
while(i != c.end()){
if (i == something)
{
//i = i.erase();
i = c.erase(i);
} else {
i++;
}
}
OR:
vector c;
for(vector<type>::iterator i=c.begin(); i != c.end(); )
{
if (some condition)
{
//i = i.erase();
i = c.erase(i);
}
else
++i;
}