Destructor in C++ by R4R Team

What is destructor?
-A destructor is a special member function that works just opposite to constructor,
-unlike constructors that are used for initializing an object, destructors destroy (or delete) the object.

When destructor get called?
Destructor is automatically called when:
-The program fincished execution.
-When a scope of the object is finished.
-When you call the delete operator.


#include < iostream>

using namespace std;
class Myclass
Myclass(int a,int b)
cout<<"This is constructor"<< endl;
cout<<"This is destructor";
int main()
Myclass obj(3,4);
return 0;


This is constructor
This is destructor

Leave a Comment:
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!