//多重继承问题
#include <iostream>
using std::cout;
using std::endl;
class Base
{
public:
void fun()
{
cout << "come from fun()" << endl;
}
};
class C_A0: public Base
{
public:
void funCA00()
{
cout << "come from class C_A0 " << endl;
}
};
class C_A1: public Base
{
public:
void funCA10()
{
cout << "come from class C_A1 " << endl;
}
};
class C_B0 : public C_A0, public C_A1//protected C_A
{
public:
void funCB00()
{
cout << "come from class C_B0" << endl;
}
C_A0 ca0Var0;
};
int main()
{
C_B0 co_CB0_Var0;
Base* p_Base_0;
p_Base_0 = (C_A0 *)&co_CB0_Var0; //C_B0类包含两个Base对象,有两个地址可以选择,所以应使用类型转换来指定对象
p_Base_0->fun();
//p_Base_0->funCB00(); //error: 'class Base' has no member named 'funCB00'
co_CB0_Var0.funCB00();
return 0;
}