标签:cout oid war space iostream 解决方案 ret ++ names
#define _CRT_SECURE_NO_WARNINGS
#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 = 10;
st.Tuo::m_Age = 20;
cout << st.Sheep::m_Age << endl;
cout << st.Tuo::m_Age << endl;
}
int main()
{
test01();
return 0;
}
标签:cout oid war space iostream 解决方案 ret ++ names
原文地址:https://www.cnblogs.com/lodger47/p/14697413.html