Actually class C constructor should have had four (Yes, 4, since it contains four variables) parameters. Anyway... Try
#include using namespace std;
class A
{
public:
int a;
A(int a):a(a){}
};
class B: public A
{
public:
int b;
B(int a, int b): A(a), b(b){}
};
class C: public B
{
public:
B obj;
C(int a, int b): B(a, b), obj(b, a){} // swapped the arguments of 'obj' just to make it a little different
friend ostream & operator << (ostream & os, const C & c); // overload the insertion operator just to show this object content
};
ostream & operator << (ostream & os, const C & c)
{
os << "a = " << c.a << ", b = " << c.b << ", obj.a = " << c.obj.a << ", obj.b = " << c.obj.b;
return os;
}
int main()
{
C obj1(10,20);
cout << obj1 << endl;
}
"In testa che avete, Signor di Ceprano?" -- Rigoletto