#include<iostream>
using namespace std;
class Animal
{
public:
int m_Age;
};
//动物类
class Sheep :virtual public Animal {};
//骆驼类
class Tuo :virtual public Animal {};
//羊驼类
class SheepTuo :public Sheep,public Tuo {};
void test01()
{
SheepTuo st;
st.Sheep::m_Age = 18;
st.Tuo::m_Age = 10;
cout << "st.Sheep::m_Age:" << st.Sheep::m_Age << endl;
cout << "st.Tuo::m_Age:" << st.Tuo::m_Age << endl;
//这份数据我们知道 只有一份就可以,菱形继承导致数据有两份,资源浪费
//利用虚继承可以解决菱形继承的问题
//在继承之前加上vertical变为虚继承
}
int main()
{
test01();
system("pause");
return 0;
}