#include<iostream>
using namespace std;
class Human
{
private:
int age;
string name;
public:
///无参//
Human(){//cout<<"Human的无参构造函数"<<endl;
};
/有参///
Human(int a,string b):age(a),name(b){
// cout<<"Human的有参构造函数"<<endl;
};
/析构函数
~Human(){
// cout<<"Human的析构函数"<<endl;
};
///void
void show()
{
cout<<"age:"<<age<<endl;
cout<<"name:"<<name<<endl;
}
};
class Student:public Human
{
private:
int score;
public:
///无参//
Student(){
// cout<<"student的无参构造函数"<<endl;
};
/有参///
Student(string a,int b,int c):score(c),Human(b,a){
// cout<<"student的有参构造函数"<<endl;
};
/析构函数
~Student(){
// cout<<"student的析构函数"<<endl;
};
///show
void show()
{
Human::show();
cout<<"score:"<<score<<endl;
}
};
class Party:public Human
{
private:
string act;
string org;
public:
///无参//
Party(){
// cout<<"Party的无参构造函数"<<endl;
};
/有参///
Party(string a,string b,int c,string d):act(a),org(b),Human(c,d){
//cout<<"Party的有参构造函数"<<endl;
};
/析构函数
~Party(){
// cout<<"Party的析构函数"<<endl;
}
///show
void show()
{
Human::show();
cout<<"act: "<<act<<endl;
cout<<"org: "<<org<<endl;
}
};
class Ganbu:public Student,public Party
{
private:
string postion;
public:
///无参f,g,h/
Ganbu(){
// cout<<"Ganbu的无参构造函数"<<endl;
};
/有参///
Ganbu(string a,string b,string c,int d,string e,string f,int g,int h):postion(a),Party(b,c,d,e),Student(f,g,h){
// cout<<"Ganbu的有参构造函数"<<endl;
}
/析构函数
~Ganbu(){
// cout<<"Ganbu的析构函数"<<endl;
};
///show
void show()
{
Student::show();
Party::show();
cout<<"postion: "<<postion<<endl;
}
};
int main(int argc, const char *argv[])
{
Ganbu g("倒垃圾的","运动会","操场",5,"ss","sy",18,2);
g.show();
return 0;
}
嵌入式9/4作业
最新推荐文章于 2024-10-05 11:02:16 发布