CONSTRUCTOR AND DESTRUCTOR
DEFINE AND USE THE CONSTRUCTOR AND DESTRUCTOR
SOURCE CODE
#include “iostream.h”
#include “conio.h”
class myclass{
int a,b;
public:
myclass();
~myclass();
void show();
};
myclass::myclass()
{
cout << "\n Constructor \n"; a=10; b=20; } myclass::~myclass() { cout << "\n Destructing… \n"; } void myclass::show() { cout << "\n A= " << b= " << b; cout << " size="4">OUTPUT
Constructor
A= 10
B= 20
Sum Is 30
Destructing…