有关C++菱形继承,需要通过虚继承解决冲突的代码
运动员
游泳人 跑步人 自行车人
铁人三项
#pragma warning(disable : 4996)
#define _CRT_SECURE_NO_WARNINGS
#include
using namespace std;
struct Athlete
{
public:
Athlete();
~Athlete();
};
Athlete::Athlete()
{
cout << "Athlete Constructor" << endl;
}
Athlete::~Athlete()
{
cout << "Athlete Destructor" << endl;
}
struct Swimmer: virtual Athlete
{
public:
Swimmer();
~Swimmer();
};
Swimmer::Swimmer()
{
cout << "Swimmer Constructor" << endl;
}
Swimm
共有 0 条评论