burning question about DELETE


[ Follow Ups ] [ Post Followup ] [ CS328 Message Board ] [ FAQ ]

Posted by basscadet on July 14, 2001 at 11:56:52:

ok....i understand how delete works only with a pointer to allocated memory returned by NEW.

I have a linked list of pointers to allocated memory. A list::iterator returns a pointer to the element in the list, accessed by *. How can i delete that object using the list iterator?

I've tried this and it doesn't work:

object* temp = *iterator;

list.erase(iterator) (removes the element from the list

delete temp; BAM! blows up.

i've also tried

delete *iterator

BAM! blows up.

WHAT DO I DO????????????????????????? help it's eating my brain!!!



Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ CS328 Message Board ] [ FAQ ]