Coders Packet

Destructors using C++

By Pratyasha Sahu

This code helps to understand the concept of destructors i.e to destroy an object using C++

Destructors helps to destroy an object which was created by a constructor.

using namespace std;
int count=0;
class destroy
cout<<"\n Number of object created="<<count;
cout<<"\n number of object destroyed="<<count;

int main()
cout<<"\n we have entered main function\n";
destroy A1, A2, A3;
cout<<"\n WE have entered the inner block\n";
destroy A4,A5;
cout<<"\n we are exiting the ineer block\n";
cout<<"\n we have returned to main \n";
cout<<"\n we are exiting main \n";
return 0;



Download Complete Code


No comments yet