#include <iostream>
using namespace std;
//多继承的概念;
//用逗号做拼接;
class Base1
{
public:
Base1()
{
m_A = 10;
}
int m_A;
int m_Same;
};
class Base2
{
public:
Base2()
{
m_B = 20;
}
int m_B;
int m_Same;
};
class Son :public Base1,public Base2
{
public:
int m_C;
int m_D;
};
void test01()
{
cout << sizeof(Son) << endl;
}
//sizeof(Son)== 16;
void test02()
{
Son s1;
cout << s1.m_A << endl;
cout << s1.m_B<< endl;
}
void test03()
{
Son s2;
//cout << s2.m_Same << endl;//Base1和Base2有同名变量,会引发二义性的问题;
cout << s2.Base1::m_Same << endl;
cout << s2.Base2::m_Same << endl;
//以此解决二义性的问题;
}
int main()
{
test01();
test02();
test03();
return 0;
}