www.itechowais.tech





Destructor in OOP | C++ :

  • It is a member function of class.
  • It is always present in Public section of class.
  • It has same name as that of class but followed by a special symbol ~ (tilde).
  • It is called automatically when an object of the class is destroyed.
  • It is not returning any value (no return type) even void also. It takes no argument.
  • It destroys memory when called.
  • Constructor is declared as-

class student
{
 private:
    int roll;
    char name[10];
  public:
    ~student();       // Destructor declaration
};