What's the use of explicitly defining a destructor?

What's the use of explicitly defining a destructor? When an object goes out of scope, its default destructor is called and memory space referenced by the *this pointer is automatically deallocated, right? Then what's the need for explicitly defining a destructor?
If your object has allocated its own memory, for example by using new, then the corresponding delete will go in the destructor.
closed account (zb0S216C)
Deallocating memory isn't the only reason why one should overload the default destructor. If your class needs to perform some specific task before it's destroyed, overloading the destructor will allow the object to do just that.

Wazzak
Topic archived. No new replies allowed.