What are Destructors?

A destructor as the name implies used to destroy the objects that have been created by constructor.
Like a constructor , the destructor is a member function whose name is same as class name but is preceded by tilde(~).
A destructor never takes any argument nor does it return nay value.
It will be invoked implicitly by compiler upon the exit from program or from a block or function.

class integer
{
        private: int m,n;
        public:integer()
       { 
                   m=0,n=0; 
       }
       ~integer() //destructor
      { 
      
      }
};

Post a Comment

Previous Post Next Post