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

灯塔引路 灯塔引路 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
/************************/
/* 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.

看着上面的错误提示 也不知道错在哪里?希望各位 能忙里偷闲 过来帮忙看看 小弟不胜感激。
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
灯塔引路
C++ 语言 65,214 成员 250,514 内容