Thursday 9 April 2015

Way of calling Constructors and Destructors

#include <iostream.h>
class B1
{
public:
B1()
{
cout<<”No-argument constructor of the base class B1”;
}
~B1()
{
cout<<”Destructor in the Base class B1”;
}
};
class B2
{
public:
B2()
{
cout<<”No-argument constructor of the base class B2”;
}
~B2()
{
cout<<”Destructor in the Base class B2”;
}
};
class D:public B1, public B2
{
public:
D()
{
cout<<”No-argument constructor of the derived class D”;
}
~D()
{
cout<<”Destructor in the Base class D”;
}
};
void main()
{
D obj;
}

No comments:

Post a Comment