#include <iostream>
using namespace std;
class Person
{
public:
Person(int a,string n)
{
age=a;
name=n;
}
void action()
{
cout<<name<<"在超市偷东西"<<endl;
}
int getAge()
{
return age;
}
string getName()
{
return name;
}
private:
int age;
string name;
};
class Polic:public Person
{
public:
Polic(int a,string n,int l):Person(a,n),level(l){}
void arrest(Person p)
{
cout<<"Polic "<<getName()<<"成功逮捕到"<<p.getName()<<endl;
}
private:
int level;
};
class Cook:public Person
{
public:
Cook(int a,string n,double s):Person(a,n),salay(s){}
void getCake(int i)
{
cout<<getName()<<" gave me "<<i<<" cakes"<<endl;
}
void Salay()
{
cout<<getName()<<"每月工资是"<<salay<<"元"<<endl;
}
private:
double salay;
};
int main()
{
Person tom(40,"Tom");
Polic jone(32,"Jone",3);
Cook alice(29,"Alice",5000);
tom.action();
jone.arrest(tom);
alice.Salay();
alice.getCake(4);
return 0;
}
using namespace std;
class Person
{
public:
Person(int a,string n)
{
age=a;
name=n;
}
void action()
{
cout<<name<<"在超市偷东西"<<endl;
}
int getAge()
{
return age;
}
string getName()
{
return name;
}
private:
int age;
string name;
};
class Polic:public Person
{
public:
Polic(int a,string n,int l):Person(a,n),level(l){}
void arrest(Person p)
{
cout<<"Polic "<<getName()<<"成功逮捕到"<<p.getName()<<endl;
}
private:
int level;
};
class Cook:public Person
{
public:
Cook(int a,string n,double s):Person(a,n),salay(s){}
void getCake(int i)
{
cout<<getName()<<" gave me "<<i<<" cakes"<<endl;
}
void Salay()
{
cout<<getName()<<"每月工资是"<<salay<<"元"<<endl;
}
private:
double salay;
};
int main()
{
Person tom(40,"Tom");
Polic jone(32,"Jone",3);
Cook alice(29,"Alice",5000);
tom.action();
jone.arrest(tom);
alice.Salay();
alice.getCake(4);
return 0;
}