C++ Language/Objects/Destructors

If a class constructor's implementation has any side-effect (e.g., allocation of memory, or opening of a file), then you usually desire the opposite side-effect to happen whenever that class' instances are going to get destroyed. The compiler knows when it's going to be destroying an object, but the programmer needs to specify that side-effect behavior within a "destructor" function which is written as.

Additional information about destructors