I need help, when i am looping through my list using iterators i need them delete themselves when they leave the screen my code is
for(salvoit = salvo.begin(); salvoit != salvo.end(); )
{
if((*salvoit)->x < 0 || (*salvoit)->x > 640)
{
delete (&salvoit);
salvoit = salvo.erase(salvoit);
}
else
{
salvoit++;
}
}
whenever i run this it gives me an error when it tries to delete the object in the list. salvo is the list and salvoit is the iterator.