Program for the destruction of Object-Oriented Programming.
Algorithm:
step1:initialize n=0
step2: create a call class
step3: declared constructor and a destructor function within a call class
step4:display ++n value using constructor
step5: display --n value using destructor
step6: within the main function create two instances of the calling class ‘c1’ and ’c2’
Program Code:
#include<iostream>
using namespace std;
int n=0;
class call
{
public:
call ()
{
cout<<”\n constructor”<<++n;
}
~call ()
{
cout<<”\n destructor”< --no;
}
};
int main ()
{
call c1, c2;
}
Thanks
Mukesh Rajput
Post A Comment:
0 comments: