using namespace std;
class base
{
int mem;
public:
base()
{
cout<<"inside base default const\n";
}
base(int x,int y):mem(x)
{
cout<<"inside base parameterized cons here mem= "<<mem<<"\n";
}
};
class child1:base
{
int mem2;
public:
child1()
{
cout<<"inside child1 default cons \n";
}
child1(int x,int y,int z):base(y,z),mem2(x)
{
cout<<"inside base parameterized cons here mem2= "<<mem2<<"\n";
}
};
class child2:child1
{
int mem3;
public:
child2(int x,int y,int z,int w):child1(y,z,w),mem3(x)
{
cout<<"inside base parameterized cons here mem3= "<<mem3<<"\n";
}
};
int main()
{
child2 ch2(10,20,30,40);
return 0;
}
Comments