Showing posts with label what is destructor. Show all posts
Showing posts with label what is destructor. Show all posts

Saturday, 31 January 2015

Destructor in C++

Structure of the Problem Requirements 

Every time when an object or instance of a class in created the constructor method is called. Destructor is used to release resource like memory releasing and file closing before coming out of the program. The program will create and destroy two constructors with destructor.

Source Code

      #include<iostream>
using namespace std;
class LEP
{
      public:
int num;
LEP ()
{
cout<<"This is a Default Constructor :"<<endl<<endl;
}
LEP (int a)
{
num = a;
cout<<" This is Intilize Constructor : "<<a<<endl<<endl;
}
~LEP ()
{
cout<<" Destructor Destruct the Construcers : "<<endl<<endl;
}
};
int main ()
{
cout<<"\t \t \t LEP Tutorials \n \n \n ";
LEP L;
LEP NB (4);
}

Output of the Program

Destructor in C++