-->
当前位置:首页 > 题库

函数题:马戏团*

Luz4年前 (2022-06-14)题库881
马戏团刚开张,只有一只猴子和一只老虎。在下面的程序里,定义了猴子类 MONKEY、老虎类 TIGER 和马戏团类 CIRCUS 类,请完成这三个类的成员函数的设计。

c++
#include <iostream>
using namespace std;
#include <string>

class MONKEY
{
public:
MONKEY(const char *name);
~MONKEY();
void Show() const;
private:
string name;
};

class TIGER
{
public:
TIGER(const char *name);
~TIGER();
void Show() const;
private:
string name;
};

class CIRCUS
{
public:
CIRCUS(const char *name, const char *monkey, const char *tiger);
~CIRCUS();
void Show() const;
private:
string name;
MONKEY monkey;
TIGER tiger;
};

/* 你提交的代码将被嵌在这里 */

int main()
{
char c[128], m[128], t[128];
cin >> c >> m >> t;
CIRCUS circus(c, m, t);
circus.Show();
return 0;
}


说明:MONKEY 为猴子类,其私有数据成员为猴子的名字。TIGER 为老虎类,其私有数据成员为老虎的名字。CIRCUS 为马戏团类,其私有成员为马戏团的名称、一只猴子和一只老虎。

#### 输入样例

in
Grant Daisy Fred


#### 输出样例

out
Monkey Daisy is born!
Tiger Fred is born!
Grant's circus is opened.
Grant's Circus.
I am Monkey Daisy.
I am Tiger Fred.
Grant's circus is closed.
Tiger Fred is dead!
Monkey Daisy is dead!








答案:若无答案欢迎评论