#include<iostream>
using namespace std;
class A
{
public:
A(int i):a(i){cout<<"调用A";cout<<a<<endl;}
private:
int a;
};
class B:public A
{
public:
B(int i,int j):A(i),aa(i),b(j){cout<<b<<endl;}
private:
A aa;
int b;
};
class C:public B
{
public:
C(int i,int j,int k):B(i,j),bb(i,j),c(k){cout<<c<<endl;}
private:
B bb;
int c;
};
int main()
{
C cc(1,2,3);
system("pause");
return 0 ;
}
运行结果:
调用A1
调用A1
2
调用A1
调用A1
2
3