#include<iostream>
#include<string>
using namespace std;
class person{
public:
person(int number1,string name1)
{
number=number1;
name=name1;
}
protected:
int number;
string name;
};
class student:public person{
public:
student(int number1,string name1,int class1,float grade1):person(number1,name1)
{
class0=class1;
grade=grade1;
}
void show()
{
cout<<"编号:"<<number<<'\t'<<"姓名:"<<name<<'\t'<<"班级:"<<class0<<'\t'<<"成绩"<<grade<<endl;
}
private:
int class0;
int grade;
};
class teacher:public person{
public:
teacher(int number1,string name1,string job1,string department1):person(number1,name1)
{
job=job1;
department=department1;
}
void show1()
{
cout<<"编号:"<<number<<'\t'<<"姓名:"<<name<<'\t'<<"职称:"<<job<<'\t'<<"部门:"<<department<<endl;
}
private:
string job;
string department;
};
int main()
{
student stu(201427,"wubeiren",1141,95.0);
stu.show();
teacher tea(01,"张三","教授","广东海洋大学");
tea.show1();
return 0;
}
作业5.18
最新推荐文章于 2024-05-19 22:50:18 发布