#include <string>
#include <iostream>
using namespace std;
class Wolf
{
public:
//狼类成员的声明
string Name;
int Shape;
void PrintState();
};
//狼类成员的定义
void Wolf::PrintState()
{
cout<<"姓名:"<<Name<<",爪子锋利度为:"<<Shape<<endl;
}
class Human
{
public:
//人类成员的声明
string Name;
int Intell;
void PrintState();
};
//人类成员的定义
void Human::PrintState()
{
cout<<"姓名:"<<Name<<",智力为:"<<Intell<<endl;
}
class Werewolf : public Wolf , Human
{
public:
//狼人类成员的声明
void SetName(string name);
void SetState(int shape,int intell);
void PrintAllState();
};
//狼人类成员的定义
void Werewolf::SetName(string name)
{
Human::Name = name;
Wolf::Name = name;
}
void Werewolf::SetState(int shape,int intell)
{
Shape = shape;
Intell = intell;
}
void Werewolf::PrintAllState()
{
Wolf::PrintState();
Human::PrintState();
}
int main()
{
int i, j;
string name;
cin >> i >> j >> name;
Werewolf ww;
ww.SetName(name);
ww.SetState(i, j);
ww.PrintAllState();
}
头歌实训项目【狼人类】
于 2022-04-14 20:48:43 首次发布