Hi all,
I have a list of pointers to objects and I am trying to delete the objects before clearing the list. Here's the code:
.................................................. .............................................
1: for (iter = addrlist.begin(); iter != addrlist.end(); iter++)
2: {
3: delete iter;
4: }
5:
6: this->addrlist.clear();
.................................................. ...............................................
I tried de-referencing iter but it kept crapping out on line 3. In line 3, iter points to a cell in the list that holds a pointer to an object. I want to delete the object first, how do I do that? TIA
BTW, here's how I am populating the list:
.................................................. ................................................
1: Addresse* add = new Addresse();
2: add->setID(LastRecordId++);
3: this->addrlist.push_back(*add);
.................................................. ................................................