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++

Share it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment