10. CPP-Destructors

CPP Constructors: Previous                                                  Next: CPP Inheritance

Destructor is used to remove the constructor from memory. It is called at the time of deallocation of constructor. Destructor have same properties /charactertics that constructor have except the look. Destructor contains tild sign(~) placed before name of it. It releases memory space for future. Example:
#include
class Sum
{
public :
Sum()
{
cout<<”constructor called “:
}
~Sum()
{
cout<<”destructor called”;
}
}:
void main()
{
Sum s1;
}

CPP Constructors: Previous                                                  Next: CPP Inheritance