5.18学生与教师管理

#include<iostream>
#include<string>
using  namespace  std;
class  person{
public:
person(string num1,string name1)
{num=num1;
name=name1;
}
void  print()
{cout<<"编号:"<<num<<endl;
cout<<"姓名:"<<name<<endl;
}
protected:
string  num;
string  name ;
};
class  student:virtual public  person{
public:
student(string num1,string name1,string  num_cl1,string  score1):
 person(name1,num1)
 {num_cl=num_cl1;
 score=score1;}
 void  print()
 {person::print();
 cout<<"班号:"<<num_cl<<endl;
 cout<<"成绩:"<<score<<endl;
 }
protected:
string num_cl;
string  score;
};
class  teacher:virtual  public person{
public:
teacher(string  num1,string name1,string  prof1,string dept1):
 person(name1,num1)
 {prof=prof1;
 dept=dept1;
 }
 void print()
 {person::print();
 cout<<"职称:"<<prof<<endl;
 cout<<"部门:"<<dept<<endl;
 }
protected:
string  prof;
string  dept;
};
int main()
{student  student1("1134667","李丽","01","90");
cout<<"学生:"<<endl;
student1.print();
cout<<"老师:"<<endl;
teacher  teacher1("2392741","Mr.wang","班主任","教务处");
teacher1.print();
return  0;
}
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值