+ 1
Why destructor is used in the class??
As per I know destructor is used to destroy the object. But I didn't get it completely. Can someone explain destructor elaborately??
1 Respuesta
+ 1
Any instance you create, will be destroyed when it stops to be valid. (For example, the function call, in which it was declared, ends.)
By defining a destructor by hand, you can say what exactly is supposed to happen when an instance is destroyed.
Sometimes that's important, for example when the instance requires memory manually, or opens a file or something like that.