Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
A C++ object is destroyed either at the end of program execution (for extern and static objects), at the exit from the closing brace of a scope (for automatic objects), when the operator delete is executed (for dynamic objects allocated with new), or when the library function free() is called (for objects allocated with malloc()).
Whenever a class object is destroyed (with the exception of the call to free()), the class destructor is called immediately before the destruction; if the class defines no destructor, the system-supplied default destructor is called (similar to default constructor, it does nothing).