destructor in c++

The destructor  is a special member function whose name is same as the class name, but it is preceded by a tiled symbol(~).

Destructor destroys class objects created by constructor.

Characteristics

  1. A destructor is automatically executed when object goes out of the scope.
  2. A destructor does not have return type and not even void.
  3. Destructor can be virtual, but constructors can not .
  4. Only one destructor can be defined in  a class.
  5. The destructor does not have any  arguments.
Scroll Up