c++编程问题,求大神打出代码,只要没错误,能运行,100悬赏请拿好 100
c++编程问题,求大神打出代码,只要没错误,能运行,100悬赏请拿好定义一个基类有姓名、性别、年龄;再由基类派生出教师类和学生类,教师类增加工号、职称和工资,学生类增加学...
c++编程问题,求大神打出代码,只要没错误,能运行,100悬赏请拿好定义一个基类有姓名、性别、年龄;再由基类派生出教师类和学生类,教师类增加工号、职称和工资,学生类增加学号、班级、专业和入学成绩;由学生类和教师类派生在职研究生类和在读教师类,在职研究生类增加工作单位。
1. 在进行多重继承中,将基类作为虚基类。
2.利用构造函数对类对象进行初始化。
3.对各种类的对象信息进行修改、添加、查询、显示等操作。
4.将教师类的职称和工资定义为private型成员,其它类的成员变量和成员函数类型依据需要定义为public或protected 或private型 展开
1. 在进行多重继承中,将基类作为虚基类。
2.利用构造函数对类对象进行初始化。
3.对各种类的对象信息进行修改、添加、查询、显示等操作。
4.将教师类的职称和工资定义为private型成员,其它类的成员变量和成员函数类型依据需要定义为public或protected 或private型 展开
展开全部
#include <iostream>
#include <string>
using namespace std;
class Human {
public:
string name;
string sex;
int old;
Human() {}
~Human() {}
string getName();
void setName(string name);
string getSex();
void setSex(string sex);
int getOld();
void setOld(int old);
};
class Teacher : virtual public Human {
public:
int numberx;
Teacher() {}
~Teacher() {}
string getName() {
return this->name;
}
void setName(string name) {
this->name = name;
}
string getSex()
{
return this->sex;
}
void setSex(string sex) {
this->sex = sex;
}
int getOld() {
return this->old;
}
void setOld(int old) {
this->old = old;
}
int getNumberX()
{
return this->numberx;
}
void setNumberX(int numberx)
{
this->numberx = numberx;
}
string getJob()
{
return this->job;
}
void setJob(string job)
{
this->job = job;
}
double getSalery()
{
return this->salery;
}
void setSalery(double salery)
{
this->salery = salery;
}
private:
string job;
double salery;
};
class Student : virtual public Human {
public:
int number;
string Class;
string profession;
int admission;
Student() {}
~Student() {}
string getName() {
return this->name;
}
void setName(string name) {
this->name = name;
}
string getSex()
{
return this->sex;
}
void setSex(string sex) {
this->sex = sex;
}
int getOld() {
return this->old;
}
void setOld(int old) {
this->old = old;
}
int getNumber()
{
return this->number;
}
void setNumber(int number)
{
this->number = number;
}
string getClass()
{
return this->Class;
}
void setClass(string Class)
{
this->Class = Class;
}
string getProfession()
{
return this->profession;
}
void setProfession(string profession)
{
this->profession = profession;
}
int getAdmission()
{
return this->admission;
}
void setAdmission(int admission)
{
this->admission = admission;
}
};
class Postgradute : public Teacher, public Student {
public:
string company;
string getName() {
return this->name;
}
void setName(string name) {
this->name = name;
}
string getSex()
{
return this->sex;
}
void setSex(string sex) {
this->sex = sex;
}
int getOld() {
return this->old;
}
void setOld(int old) {
this->old = old;
}
Postgradute() {}
~Postgradute() {}
string getCompany() {
return this->company;
}
void setCompany(string company) {
this->company = company;
}
};
class StuTeacher : public Teacher, public Student {
public:
StuTeacher() {}
~StuTeacher(){}
};
void main()
{
Postgradute pg = Postgradute();
pg.setName("test");
pg.setAdmission(88);
pg.setClass("two");
pg.setCompany("DUT");
pg.setJob("HelpTeacher");
pg.setOld(18);
pg.setProfession("software");
pg.setSalery(1000);
pg.setSex("boy");
pg.setNumber(10192582);
pg.setNumberX(201193247);
cout << pg.getName() << endl
<< pg.getAdmission() << endl
<< pg.getCompany() << endl
<< pg.getJob() << endl
<< pg.getNumber() << endl
<< pg.getNumberX() << endl
<< pg.getOld() << endl
<< pg.getProfession() << endl
<< pg.getSalery() << endl
<< pg.getSex() << endl;
}
追问
额,朋友,题里说的那些功能一个没有啊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询