Skip to main content
GameDev.net gamedev.net
🔒 Locked

STL dealloc

Started by Thygrrr Jun 3, 2004 at 6:45 PM 4 replies 350+ views
Original Post
Thygrrr
Thygrrr
What happens to the leftover elements for example in a std::vector when it is not empty() at the time it's destroyed? [edited by - Thygrrr on June 3, 2004 7:45:31 PM]
noVum
noVum
They are destroyed as well.
noVum
noVum
That's not what he asked. In that case the elements are pointers and they ARE destroyed.

It is consequential that the objects they point to are NOT destroyed.

[edited by - noVum on June 3, 2004 7:52:41 PM]
Thygrrr
Thygrrr
Thanks for the quick replies

The answer is what I assumed, but I wasn''t at all sure whether I had to pop_back() every element upon deletion of the vector or whether I could just iterate through its elements (which are pointers in my case), delete the objects they point to, and let the vector''s destructor take care of the actual pointers.

It''s all clear now!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.