list reomve function


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]

Posted by kaden yealy on April 20, 2001 at 16:21:02:

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)
{
AnimalList->remove(*p);
}
p++;


Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]