有一个BUG错误 求各位帮帮吧?

灯塔引路 2013-11-11 09:51:38
/************************/
/* example of 5.7 */
/************************/

#include<iostream>
#include<string>
using namespace std;


/*********************************************************/
/* class of Employee */
/*********************************************************/
class Employee
{
protected:
char *name; //the number of employee
int individualEmpNo;
int grade; //work position
float accumPay;
static int employeeNo; //The max number of compus emploayee number
public:
Employee()
{name=new char[];
individualEmpNo=employeeNo++;
cout<<"职工姓名:";
cin>>name;
accumPay=0.0;
}

~Employee()
{
cout<<"destructe employee class"<<endl;
}
virtual void pay()=0;
//virtual void promote(); //the money of promote
virtual void displayStatus();
};

/*********************************************************/
/* class of Technician */
/*********************************************************/
class Technician:public Employee
{
private:
float hourlyRate; //the salary of a hour
int workHours; //work hour
public:
Technician()
{
hourlyRate=100;
cout<<name<<"本月工作时间:";
cin>>workHours;
}

void pay()
{
accumPay=hourlyRate*workHours;
}
void displayStatus()
{
cout<<"兼职技术人员:"<<name<<",编号:";
cout<<individualEmpNo<<",本月工资:"<<accumPay<<endl;
}
};

/*********************************************************/
/* class of Manager */
/*********************************************************/
class Manager:virtual public Employee
{
protected:
float monthlyPay;

public:

Manager()
{
monthlyPay=8000;
}

void pay()
{
accumPay=monthlyPay;
}
void displayStatus()
{
cout<<"经理:"<<name<<",编号:";
cout<<individualEmpNo<<",本月工资:"<<accumPay<<endl;
}

};

/*********************************************************/
/* class of Salesman */
/*********************************************************/
class Salesman:virtual public Employee
{
protected:
float commRate;
float sales; //salary of monthy
public:
Salesman()
{
commRate=0.04f;
cout<<name<<"本月销售额:";
cin>>sales;
}
void pay()
{
accumPay=sales*commRate;
}
void display()
{
cout<<"销售员:"<<name<<",编号:";
cout<<individualEmpNo<<",本月工资:"<<accumPay<<endl;
}
};


/*********************************************************/
/* class of Salesmanager */
/*********************************************************/
class Salesmanager:public Manager,public Salesman
{
public:
Salesmanager()
{
monthlyPay=5000;
commRate=0.05f;
cout<<name<<"所管部门月销售量:";
cin>>sales;
}
void pay()
{
accumPay=monthlyPay+commRate*sales;
}

void displayStatus()
{
cout<<"销售经理:"<<name<<",编号:"<<individualEmpNo<<":本月工资:"<<accumPay<<endl;
}
};

int Employee::employeeNo=10000;

int main()
{
Manager m1;
Technician t1;
Salesman s1;
Salesmanager sm1;

Employee *em[4]={&m1,&t1,&s1,&sm1};
cout<<"上述人员的基本信息为:"<<endl;

for(int i=0;i<4;i++)
{
em[i]->pay();
em[i]->displayStatus();
}
return 0;
}

--------------------------------------------------------------------------
Linking...
SDFAs.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall Employee::displayStatus(void)" (?displayStatus@Employee@@UAEXXZ)
Debug/ddsaaA.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

看着上面的错误提示 也不知道错在哪里?希望各位 能忙里偷闲 过来帮忙看看 小弟不胜感激。
...全文
97 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Burcy Wen 2013-11-11
  • 打赏
  • 举报
回复
virtual void displayStatus(); 改为 virtual void displayStatus(){}; 试试
ouyh12345 2013-11-11
  • 打赏
  • 举报
回复
基类Employee的displayStatus函数没有实现 这样: void displayStatus() { }
版主大哥 2013-11-11
  • 打赏
  • 举报
回复
Manager m1;Technician t1;Salesman s1;Salesmanager sm1; 有的类里没有实现基类的虚函数

64,683

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧