#include <iostream>
#include <cstring>
using namespace std;
class Student //学生类
{
private:
string name; //姓名
int year; //年龄
double sorce; //分数
public:
Student (){} //无参构造
Student(string a,int b,double c):name(a),year(b),sorce(c){} //有参构造
~Student() {} //析构函数
void show()
{
cout<<"student.name="<<name<<endl;
cout<<"student.year="<<year<<endl;
cout<<"student.sorce="<<sorce<<endl;
}
friend class Student_cadres; //设为学生干部类的友元
};
class Party //党员类
{
private:
string huodong; //党组织活动
string zuzhi; //组织
public:
Party (){} //无参构造
Party(string a,string b):huodong(a),zuzhi(b){} //有参构造
~Party(){} //析构函数
void show()
{
cout<<"party.huodong="<<huodong<<endl;
cout<<"party.zuzhi="<<zuzhi<<endl;
}
friend class Student_cadres; //设为学生干部类的友元
};
class Student_cadres:public Student,public Party
{
private:
string position; //职位
public:
Student_cadres (){} //无参构造
Student_cadres(string name,int year,double sorce,string huodong, string zuzhi,string f):Student(name,year,sorce),Party(huodong,zuzhi),position(f){} //有参构造
~Student_cadres() {} //析构函数
void show(); //声明学生干部类的show函数
};
void Student_cadres::show() //执行学生干部类的show函数
{
cout<<"student.name="<<name<<endl;
cout<<"student.year="<<year<<endl;
cout<<"student.sorce="<<sorce<<endl;
cout<<"party.huodong="<<huodong<<endl;
cout<<"party.zuzhi="<<zuzhi<<endl;
cout<<"student_cadres.position="<<position<<endl;
}
int main()
{
Student_cadres s1("zhangsan",18,98.5,"laoniangongyu","shaoxianduiyuan","laoda");
s1.show();
return 0;
}