定义一个人员类person

来源:百度知道 编辑:UC知道 时间:2024/05/18 00:30:07
定义一个人员类person,包括成员变量:编号、姓名、性别和用于输入输出的成员函数。在此基础上派生出学生类student(增加成绩)和教师类teacher(增加教龄),并实现对学生和教师信息的输入输出。
写得越简单越好.我刚学C++

////////////person头文件///////////
#ifndef PERSON_H
#define PERSON_H
#include <string>
#include <iostream>
using namespace std;

class person
{
public:
person();
//void SetNum(int NewNum);
//void SetName(string NewName);
//void SetSex(string NewSex);
void Input();
//int GetNum() const;
//string GetName() const;
//string GetSex() const;
void Output() const;

private:
int num;
string name;
string sex;
};

#endif

////////////student头文件///////////

#ifndef STUDENT_H
#define STUDENT_H
#include "person.h"
class student:public person
{
public:
student();
void Input();
void Output() const;

private:
float score;
};
#endif
////////////teacher头文件///////////

#ifndef TEACHER_H
#define TEACHER_H
#incl