Destructor

tutorial and example
tutorial and example

C++ Destructor

Destructor is used to destroy the objects created by a constructor. Name of destructor is same as the name of class but it preceded by a tilde(~).

Destructor neither takes any argument nor returns any value. Compiler implicitly invokes upon the destructor to exit from the program.

Syntax:

C++ Destructor Example

Output: