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); }
0 comments:
Post a Comment