Jul 10, 2005 #1 butthead Programmer Feb 24, 2002 545 US I ceate an object with "new". I add this to a vector using "push_back ()". I remove the object with "erase ()". question does erase do the delete stuff to clean up the trash, or do I have to do it myself. thanks in advance. tomcruz.net
I ceate an object with "new". I add this to a vector using "push_back ()". I remove the object with "erase ()". question does erase do the delete stuff to clean up the trash, or do I have to do it myself. thanks in advance. tomcruz.net
Jul 11, 2005 #2 TonyGroves Programmer Aug 13, 2003 2,389 IE push_back() copies the object to the vector, and erase() removes the copy from the vector. So yes, you will have to delete the original object. Upvote 0 Downvote
push_back() copies the object to the vector, and erase() removes the copy from the vector. So yes, you will have to delete the original object.
Jul 11, 2005 Thread starter #3 butthead Programmer Feb 24, 2002 545 US so this is the corrrect way to clean up the memory. Code: table = TableArray [x]; TableArray.erase(TableArray.begin() + x); delete table; tomcruz.net Upvote 0 Downvote
so this is the corrrect way to clean up the memory. Code: table = TableArray [x]; TableArray.erase(TableArray.begin() + x); delete table; tomcruz.net