33,311
社区成员
发帖
与我相关
我的任务
分享
//Person.h
#ifndef _PERSON_H
#define _PERSON_H
class Person
{
protected:
char *chp_name;
char *chp_id;
float f_workTime;
public:
Person(char*,char*,float);
virtual void display(char*);
virtual float getWorkTime();
};
#endif
//EmployeeH.h
#ifndef _TEACHER_H
#define _TEACHER_H
#include "PersonH.h"
class Employee:public Person
{
protected:
float f_sallary;
public:
Employee(char*,char*,float,float);
~Employee();
virtual void display(char*);
//virtual float getWorkTime();
virtual float getSallary();
virtual void setSallary(float);
};
#endif
//TeacherH.h
#ifndef _TEACHER_H
#define _TEACHER_H
class Teacher
{
public:
Teacher(char*,char*,float,float);
~Teacher();
};
#endif
//ObjDefine.cpp
Employee::Employee(char* name,char* id,float workTime,float sallary):Person(name,id,workTime)
{
this->chp_id = id;//注意 这样传直很危险!!!
this->chp_name = name;
this->f_workTime = workTime;
this->f_sallary = sallary;
}
Employee::~Employee()
{
cout<<"一个雇员对象("<<this->chp_name<<")成功的被删除"<<endl;
}
//****ObjDefine.cpp(114) : error C2653: 'Teacher' : is not a class or namespace name*****
Teacher::Teacher(char* name,char* id,float workTime,float sallary):Employee(name,id,workTime,sallary):Person(name,id,workTime)
{
//此函数出现错误!!!!!
}
Teacher::~Teacher()
{
cout<<"一个教师对象("<<this->chp_name<<")成功的被删除"<<endl;
}
//enter.cpp
#include <iostream>
#include <string>
#include "PersonH.h"
#include "EmployeeH.h"
#include "TeacherH.h"
#include "StudentH.h"
using std::cin;
using std::cout;
using std::endl;
int main()
{
return 0;
}
//teacher.h
#ifndef _TEACHER_H
#define _TEACHER_H
class Teacher:Employee
{
public:
Teacher(char*,char*,float,float);
~Teacher();
};
#endif
//ObjDefine.cpp
#include <iostream>
#include <string>
#include "PersonH.h"
#include "EmployeeH.h"
#include "TeacherH.h"
#include "StudentH.h"
using std::cin;
using std::cout;
using std::endl;
Employee::Employee(char* name,char* id,float workTime,float sallary):Person(name,id,workTime)
{
this->chp_id = id;//注意 这样传直很危险!!!
this->chp_name = name;
this->f_workTime = workTime;
this->f_sallary = sallary;
}
Employee::~Employee()
{
cout<<"一个雇员对象("<<this->chp_name<<")成功的被删除"<<endl;
}
void Employee::display(char *idColName)
{
cout<<"***************雇员*******************"<<endl;
Person::display(idColName);
cout<<"职称:";
if(this->f_workTime<3){cout<<"助教"<<endl;}
else if(this->f_workTime<5)cout<<"讲师"<<endl;
else cout<<"教授"<<endl;
cout<<"**********************************"<<endl<<endl;
}
float Employee::getSallary()
{
return this->f_sallary;
}
void Employee::setSallary(float sallary)
{
this->f_sallary = sallary;
}
//***此处报错 error C2653: 'Teacher' : is not a class or namespace name
Teacher::Teacher(char* name,char* id,float workTime,float sallary):Employee(name,id,workTime,sallary):Person(name,id,workTime)
{
}
//teacher.h
#ifndef _TEACHER_H
#define _TEACHER_H
class Teacher:Employee
{
public:
Teacher(char*,char*,float,float);
~Teacher();
};
#endif
//ObjDefine.cpp
#include <iostream>
#include <string>
#include "PersonH.h"
#include "EmployeeH.h"
#include "TeacherH.h"
#include "StudentH.h"
using std::cin;
using std::cout;
using std::endl;
Employee::Employee(char* name,char* id,float workTime,float sallary):Person(name,id,workTime)
{
this->chp_id = id;//注意 这样传直很危险!!!
this->chp_name = name;
this->f_workTime = workTime;
this->f_sallary = sallary;
}
Employee::~Employee()
{
cout<<"一个雇员对象("<<this->chp_name<<")成功的被删除"<<endl;
}
void Employee::display(char *idColName)
{
cout<<"***************雇员*******************"<<endl;
Person::display(idColName);
cout<<"职称:";
if(this->f_workTime<3){cout<<"助教"<<endl;}
else if(this->f_workTime<5)cout<<"讲师"<<endl;
else cout<<"教授"<<endl;
cout<<"**********************************"<<endl<<endl;
}
float Employee::getSallary()
{
return this->f_sallary;
}
void Employee::setSallary(float sallary)
{
this->f_sallary = sallary;
}
//***此处报错 error C2653: 'Teacher' : is not a class or namespace name
Teacher::Teacher(char* name,char* id,float workTime,float sallary):Employee(name,id,workTime,sallary):Person(name,id,workTime)
{
}