学生数据要求有编号,姓名,班号和成绩,教师数据有编号,姓名,职称和部门。要求将编号,姓名的输入和显示设计成一个类person,并作为学生数据操作类student和教师数据操作类teacher的基类。学生数据中的班号和成绩的输入和显示在student类中实现,教师数据中的职称和部门的输入和显示在teacher类中实现,最后在主函数中进行该类的测试。
基类person的主要成员包括:私有成员:int no编号和string name姓名;
公有成员:input()函数用于输入姓名和编号;
display()函数用于显示姓名和编号。
源代码如下:
#include <iostream>
#include <string>
using namespace std;
class person
{
public:
void input()
{
std::cout << "请输入编号:" ;
std::cin >> no;
std::cout << "请输入姓名:" ;
std::cin &g