Write A Program For Destructor In C++


Write A Program For Destructor In C++

#include<iostream>
#include<conio.h>

//Standard Namespace Declaration

using namespace std;

class BaseClass // Class Name
{
public:
   //Constructor of the BaseClass
   BaseClass() {
      cout << "Constructor of the BaseClass : Object Created"<<endl;
   }
       
   //Destructor of the BaseClass
   ~BaseClass() {
      cout << "Destructor of the BaseClass : Object Destroyed"<<endl;
   }
};


int main ()
{
        // Object Declaration for BaseClass
        BaseClass des;
   
        // Wait For Output Screen
        getch();

        //Main Function return Statement
        return 0;
}

OUTPUT:-
Constructor of the BaseClass : Object Created                                                                                 
Destructor of the BaseClass : Object Destroyed 


Comments