Destructor: –

Destructor: – It is also a special member function just like constructor. The purpose of it is to destroy the memory allocation of an object. When the object goes out of the scope when the object are created. There are following some rule –

  1. It must also have same name as of its class name which is prefixed with tilde (~) operator.
  2. It does not have return type as well as formal argument.
  3. Inside one class we can have only one destructor so destructor cannot be overload.

Syntax: –

                                _ _ _ _ _

Ex: –

                                _ _ _ _ _

Comments are closed.

Create a website or blog at

Up ↑

%d bloggers like this: