求C++答案
发布网友
发布时间:2022-10-06 23:19
我来回答
共1个回答
热心网友
时间:2023-10-24 08:00
#ifndef _MANAGE_PERSON_BASE_H_
#define _MANAGE_PERSON_BASE_H_
#include <string>
using std::string;
class CMangePersonBase
{
public:
CMangePersonBase()
{
printf("this is CMangePersonBase.\n");
}
virtual float GetBasePay(void) = 0;
virtual std::string GetTechnicalPost(void) = 0;
virtual std::string GetName(void) = 0;
virtual std::string GetEmployeeNumber(void) = 0;
protected:
std::string m_sTechnicalPost;
std::string m_sName;
std::string m_sEmployeeNumber;
float m_fBasePay;
};
#endif // manageperson.h
#ifndef _CHAIRMAN_H_
#define _CHAIRMAN_H_
#include "ManagePersonBase.h"
class CChairman : virtual public CMangePersonBase
{
public:
CChairman()
{
printf("this is CChairman.\n");
}
virtual float GetBasePay(void)
{
return m_fBasePay;
}
virtual std::string GetTechnicalPost(void)
{
return m_sTechnicalPost;
}
virtual std::string GetName(void)
{
return m_sName;
}
virtual std::string GetEmployeeNumber(void)
{
return m_sEmployeeNumber;
}
virtual int GetManageClassNumber(void)
{
return m_nManageClassNumber;
}
protected:
int m_nManageClassNumber;
};
#endif // chairman.h
#ifndef _TEACHER_H_
#define _TEACHER_H_
#include "ManagePersonBase.h"
class CTeacher : virtual public CMangePersonBase
{
public:
CTeacher()
{
printf("this is CTeacher.\n");
}
virtual float GetBasePay(void)
{
return m_fBasePay;
}
virtual std::string GetTechnicalPost(void)
{
return m_sTechnicalPost;
}
virtual std::string GetName(void)
{
return m_sName;
}
virtual std::string GetEmployeeNumber(void)
{
return m_sEmployeeNumber;
}
virtual int GetMonthTeacherNumber(void)
{
return m_nMonthTeacherNumber;
}
protected:
int m_nMonthTeacherNumber;
};
#endif // teacher.h
#ifndef _TEACHER_CHAIRMAN_H_
#define _TEACHER_CHAIRMAN_H_
#include "Teacher.h"
#include "Chairman.h"
class CTeacherChairman : public CTeacher,public CChairman
{
public:
CTeacherChairman()
{
printf("this is CTeacherChairman.\n");
}
virtual float GetBasePay(void)
{
return m_fBasePay;
}
virtual string GetTechnicalPost(void)
{
return m_sTechnicalPost;
}
virtual string GetName(void)
{
return m_sName;
}
virtual string GetEmployeeNumber(void)
{
return m_sEmployeeNumber;
}
virtual int GetMonthTeacherNumber(void)
{
return m_nMonthTeacherNumber;
}
virtual int GetManageClassNumber(void)
{
return m_nManageClassNumber;
}
};
#endif // teacherchairman.h
// person.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <stdlib.h>
#include "Teacher.h"
#include "Chairman.h"
#include "TeacherChairman.h"
int main(int argc, _TCHAR* argv[])
{
CChairman Chairman;
CTeacher Teacher;
CTeacherChairman TercherChairman;
system("pause");
return 0;
}追问大神,我还有2题没解决的 帮忙一下好吗