第十/十一周训练4-2

#include<iostream>
#include<string>
using namespace std;
class Person
{
private:
int age;
string name;
public:
Person(int ag,string na):age(ag),name(na){}
void action()
{
cout<<age<<"   "<<name<<endl;
}
};
class Polic:public Person
{
private:
int level;
Person leader;
public:
Polic(int ag,string na,int le,int ag2,string na2):Person(ag,na),leader(ag2,na2),level(le){}
void arrest()
{
action();
cout<<level<<endl;
}
};
class Cook:public Person
{
private:
double salary;
Person protector;
public:
Cook(int ag,string na,double sa,int ag2,string na2):Person(ag,na),protector(ag2,na2),salary(sa){}
void getCake()
{
action();
cout<<salary<<endl;
}
};




int main()
{
    Polic A(1,"asd",3,6,"cxc");
A.arrest();
Cook B(4,"qwrr",6,45,"bnvf");
B.getCake();
}*/

你可能感兴趣的:(第十/十一周训练4-2)