When you remove an object from an stl container. Is the destructor for the object called?
Do you need to keep a refrence to the object and call the destructor explicitly.
Printable View
When you remove an object from an stl container. Is the destructor for the object called?
Do you need to keep a refrence to the object and call the destructor explicitly.
>When you remove an object from an stl container. Is the destructor for the object called?
It would be terribly inconvenient if it weren't, don't you think? :)
>Do you need to keep a refrence to the object and call the destructor explicitly.
You rarely need to call a destructor explicitly. Unless you're sure, assume that the standard library will "do the right thing".
Thnks Prelude was just a little worried and unsure.
If your unsure, write a small test program. (eg One where the destructor just prints something and see if it is called when you remove the object.)
Cheers