Posted by Daniel Longest on April 20, 2001 at 17:20:01:
In Reply to: list reomve function posted by kaden yealy on April 20, 2001 at 16:21:02:
Calling remove on an std::list invalidates the iterator used in the remove. In other words, you can't increment it after the removal because it's not valid. http://rcs21.urz.tu-dresden.de/docs/STL_doc/List.html
: I keep getting a runtime error and my program crashes whenever I try to incerement my iterator after I remove my creature* from my list. It uns through the list nad loads it correctly and can incerement fine with iterators, but I cant delete the item the iterator points to an contine in my list. Below is the basic way I'm tryin to run to test if creature should die. p is the iterator of AnimalList. The item is removed correctly but then once it ends the if condition it runs into an error and crashes. Anyone famalier with how to remove an element and then contine in the list please let me know.
: if((*p)->getEnergy() <=0)
Post a Followup