#include<iostream>
using namespace std;
class human
{
public:
void stand(){cout<<"人类能够直立行走!"<<endl;}
};
class father: virtual public human
{
public:
};
class mother: virtual public human
{
public:
};
class son:public mother,public father
{
public:
};
void main()
{
son Tom;
father Mike;
mother Jane;
Tom.stand(); //正确,成功调用子类的唯一的stand()函数
Jane.stand(); //正确,成功调用母类的唯一的stand()函数
Mike.stand(); //正确,成功调用父类的唯一的stand()函数
}
using namespace std;
class human
{
public:
void stand(){cout<<"人类能够直立行走!"<<endl;}
};
class father: virtual public human
{
public:
};
class mother: virtual public human
{
public:
};
class son:public mother,public father
{
public:
};
void main()
{
son Tom;
father Mike;
mother Jane;
Tom.stand(); //正确,成功调用子类的唯一的stand()函数
Jane.stand(); //正确,成功调用母类的唯一的stand()函数
Mike.stand(); //正确,成功调用父类的唯一的stand()函数
}