class Father1 {//父类
public:
Father1() {
a = 100;
}
int a;
};
class Father2 {//父类
public:
int a;
Father2() {
a = 200;
}
};
class Son :public Father1 , public Father2{//子类多继承 calss A: 权限 类名 , 权限 类名
public:
Son() {
a = 300;
}
int a;
};
void test() {//通过对象调用
Son son;
cout << son.a << endl;
cout << son.Father1::a << endl;//加上对应的作用域进行访问
cout << son.Father2::a << endl;
}
int main() {
test();
}
/*结果:
300
100
200
*/