/*
定义一个人员类CPerson, 姓名char cName[20]、编号int nNum、性别char cSex。
在此基础上派生出学生类CStudent(增加数据成员:成绩float fScore)
和教师类CTeacher(增加数据成员:教龄int nSchoolAge)。
要求:
(1)基类和派生类均有带参的构造函数,能够对派生类中所有数据成员初始化;
(2)派生类中定义OutPut()函数,能够对派生类中所有数据成员值进行输出;
*/
#include <iostream>
#include <string.h>
using namespace std;
class CPerson{
public:
CPerson(){};
CPerson(char name[],int n,char sex);
protected:
char cName[20];
int nNum;
char cSex;
};
class CStudent:CPerson{
public:
CStudent(char *name,int n,char sex,float score);
void OutPut();
private:
float fScore;
};
class CTeacher:CPerson{
public:
CTea
定义一个人员类CPerson, 姓名char cName[20]、编号int nNum、性别char cSex。
在此基础上派生出学生类CStudent(增加数据成员:成绩float fScore)
和教师类CTeacher(增加数据成员:教龄int nSchoolAge)。
要求:
(1)基类和派生类均有带参的构造函数,能够对派生类中所有数据成员初始化;
(2)派生类中定义OutPut()函数,能够对派生类中所有数据成员值进行输出;
*/
#include <iostream>
#include <string.h>
using namespace std;
class CPerson{
public:
CPerson(){};
CPerson(char name[],int n,char sex);
protected:
char cName[20];
int nNum;
char cSex;
};
class CStudent:CPerson{
public:
CStudent(char *name,int n,char sex,float score);
void OutPut();
private:
float fScore;
};
class CTeacher:CPerson{
public:
CTea