警察与厨师
来源:互联网 发布:手机淘宝怎么赚钱 编辑:程序博客网 时间:2024/06/09 20:17
#include <iostream>
using namespace std;
class Person
{
public:
Person(int, string);
void action();
string getName()
{
return name;
}
private:
int age;
string name;
};
Person::Person(int a, string n):age(a), name(n) {}
void Person::action()
{
cout<<name<<" do some action"<<endl;
}
class Police: public Person
{
public:
Police(int, string, int);
void arrest(Person);
private:
int level;
};
Police::Police(int a, string n, int l):Person(a,n),level(l) {}
void Police::arrest(Person p)
{
cout<<" Police "<<getName()<<" arrest " <<p.getName()<<endl;
}
class Cook: public Person
{
public:
Cook(int, string, double);
void getCake(int);
private:
double salary;
};
Cook::Cook(int a, string n, double s):Person(a,n),salary(s) {}
void Cook::getCake(int n)
{
cout<<" Cook "<<getName()<<" gave me " <<n<<" cakes."<<endl;
}
int main()
{
Person tom(120,"Tom");
Police jack(30,"Jack",2);
Cook john(24,"John",5000);
jack.arrest(tom);
john.getCake(4);
return 0;
}
using namespace std;
class Person
{
public:
Person(int, string);
void action();
string getName()
{
return name;
}
private:
int age;
string name;
};
Person::Person(int a, string n):age(a), name(n) {}
void Person::action()
{
cout<<name<<" do some action"<<endl;
}
class Police: public Person
{
public:
Police(int, string, int);
void arrest(Person);
private:
int level;
};
Police::Police(int a, string n, int l):Person(a,n),level(l) {}
void Police::arrest(Person p)
{
cout<<" Police "<<getName()<<" arrest " <<p.getName()<<endl;
}
class Cook: public Person
{
public:
Cook(int, string, double);
void getCake(int);
private:
double salary;
};
Cook::Cook(int a, string n, double s):Person(a,n),salary(s) {}
void Cook::getCake(int n)
{
cout<<" Cook "<<getName()<<" gave me " <<n<<" cakes."<<endl;
}
int main()
{
Person tom(120,"Tom");
Police jack(30,"Jack",2);
Cook john(24,"John",5000);
jack.arrest(tom);
john.getCake(4);
return 0;
}
0 0
- 警察与厨师
- 警察与厨师
- 警察与厨师2
- 警察与厨师
- 警察与厨师
- 警察与厨师2
- 警察与厨师
- 项目32-警察与厨师
- 警察与厨师(1)
- 警察与厨师(2)
- C++实践参考:警察与厨师
- 第十周项目42-警察与厨师
- 第10、11周-警察与厨师
- 第十周——警察与厨师
- 第十,十一周,警察与厨师2
- 第十一周项目三警察与厨师
- 警察和厨师
- 警察和厨师
- 先建立临时表再查询
- Linux 下常用 ftp 命令
- spring 切面,暂无更深理解
- 使用Gson解析Json数据案例
- 三种基本的存储引擎比较
- 警察与厨师
- 存储过程 返回值 procedure return values
- Android获取系统相册图片并裁剪(兼容4.4以上版本)
- JSON工具类总结
- 利用OpenCV的函数createTrackbar创建滑动条查看二值化的最佳阈值的源码及讲解
- SpringMVC学习系列(2) 之 经典的HelloWorld实现
- WPF开发一款软件自动升级组件
- MD5(C++实现)
- strong,weak,retain,assign,copy nomatic 等的区别