嵌入式9/4作业

#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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值