Destructor Question...
-
How do you know when an object is going to destruct? Provided you don't implicitly call the destructor. Thanks in advance. -CDudd
If you create the object with
new
the destructor is called as part of the operations performed bydelete
. If the object is created on the stack (nonew
), the destructor is called when the object goes out of scope (e.g. if it is a local variable inside a function, the destructor is called when the function exits). Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
How do you know when an object is going to destruct? Provided you don't implicitly call the destructor. Thanks in advance. -CDudd
An object is destructed when explicitly
delete
d or when it goes out of scope, if created on the stack. An object is also destructed when its containing object (if any) is destructed. This applies to implicitly constructed members of the containing class. Dynamically created members need to be explicitlydelete
d. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com