#include<iostream.h>
#include<conio.h>
class base
{
protected:
int a;
public:
base(int x)
{
a=x;
cout<<"Inside base constructor"<<endl;
}
~base()
{
cout<<"Inside base destructor"<<endl;
}
};//end of base class
class derived1 : public base
{
protected:
int b;
public:
derived1(int x,int y):base(x)
{
b=y;
cout<<"Inside derived1 constructor"<<endl;
}
~derived1()
{
cout<<"Inside derived1 destructor"<<endl;
}
};//end of derived class
class derived2 : public derived1
{
int c;
public:
derived2(int x,int y,int z):derived1(x,y)
{
c=z;
cout<<"Inside derived2 constructor"<<endl;
}
~derived2()
{
cout<<"Inside derived2 destructor"<<endl;
}
void show()
{
cout<<"a : "<<a<<" "<<"b : "<<b<<" "<<"c : "<<c<<endl;
}
};//end of derived class
void main()
{
clrscr();
derived2 obj(3,4,5);
obj.show();
}
/*
Inside base constructor
Inside derived1 constructor
Inside derived2 constructor
a : 3 b : 4 c : 5
Inside derived2 destructor
Inside derived1 destructor
Inside base destructor
*/
thank you.....helped a lot
ReplyDeleteThis excellent website truly has all the information and facts I
ReplyDeleteneeded concerning this subject and didn't know who to ask.
My site - cellulite treatment reviews
thanks a lot
ReplyDeleteVery informative article.Thank you author for posting this kind of article .
ReplyDeletehttp://www.wikitechy.com/view-article/insertion-sorting-
program-in-cpp-with-example-and-explanation
Both are really good,
Cheers,
Venkat
Useful post about constructor and destructor in multiple inheritance..java training in chennai
ReplyDeleteVery informative ..i suggest this blog to my friends..Thank you for sharingjava training in chennai | chennai's no.1 java training in chennai | best java institute in chennai
ReplyDeleteIt’s great to come across a blog every once in a while that isn’t the same out of date rehashed material. Fantastic read.
ReplyDeleteDevops Course Training in Chennai |Best Devops Training Institute in Chennai
Selenium Course Training in Chennai |Best Selenium Training Institute in Chennai
Java Course Training in Chennai | Best Java Training Institute in Chennai
browse around these guys replica bags toronto site link replica bags los angeles replica dolabuy replica bags paypal
ReplyDelete