#include<iostream>
#include<string>
using namespace std;
class Person{
protected:
string number_id;
string name;
public:
Person(string i,string n)
{
number_id=i;
name=n;
}
void print()
{
cout<<"number_id:"<<number_id<<"\n";
cout<<"name:"<<name<<"\n";
}
};
class Student:public Person{
private:
int class1;
float score;
public:
Student(string i,string n,int c,float s):Person(i,n)
{
class1=c;
score=s;
}
void print()
{
Person::print();
cout<<"class1:"<<class1<<"\n";
cout<<"score:"<<score<<"\n";
}
};
class Teacher:public Person{
private:
string profession;
string department;
public:
Teacher(string i,string n,string p,string d):Person(i,n)
{
profession=p;
department=d;
}
void print()
{
Person::print();
cout<<"profession:"<<profession<<"\n";
cout<<"department:"<<department<<"\n";
}
};
int main()
{
Student stu1("201411671230","张瀚",1142,90);
stu1.print();
Teacher tea1("2014","易学明","教授","信息学院");
tea1.print();
return 0;
}
5.18作业
最新推荐文章于 2024-05-19 18:06:00 发布