Destructor

C++ Destructor

Destructor is used to destroy the objects created by a constructor. Name of the 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:

Leave a Comment