It's the same with inheritance too!
Code:
class B
{
public:
int theInt;
B():theInt(0) { cout << "B, theInt=" << theInt << endl; };
B(int x):theInt(x) { cout << "B, theInt=" << theInt << endl; };
};
class A : public B
{
public:
int i;
A():B(),i(0) {
cout<<"A1:";
cout<<"i="<<i<<endl;
cout<<"A1 End"<<endl;
}
A(int x):B(x)
{
cout<<"A2:";
cout<<"i="<<i<<endl;
B();
A();
cout<<"A:B, theInt=" << B::theInt<<endl;
cout<<"i="<<i<<endl;
cout<<"A2 End"<<endl;
}
};
int main()
{
A obj(2);
system("pause");
return EXIT_SUCCESS;
}