主题:vc6.0遇到link错误,求助
10_16.obj : error LNK2001: unresolved external symbol "public: void __thiscall technician::setworkhours(int)" (?setworkhours@technician@@QAEXH@Z)
employee.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall salesman::pay(void)" (?pay@salesman@@UAEXXZ)
Debug/082402十.exe : fatal error LNK1120: 2 unresolved externals
代码如下:
//employee.h
class employee
{
protected:
char name[20];
int individualempno;
int grade;
float accumpay;
static int employeeno;
public:
employee();
~employee();
virtual void pay()=0;
virtual void promote(int increment = 0);
void setname (char *);
char * getname();
int getindividualempno();
int getgrade();
float getaccumpay();
};
class technician:public employee
{
private:
float hourlyrate;
int workhours;
public:
technician();
void setworkhours(int wh);
void pay();
void promote(int);
};
class salesman:virtual public employee
{
protected:
float commrate;
float sales;
public:
salesman();
void setsales(float sl);
void pay();
void promote(int);
};
class manager:virtual public employee
{
protected:
float monthlypay;
public:
manager();
void pay();
void promote(int);
};
class salesmanager:public manager,public salesman
{
public:
salesmanager();
void pay();
void promote(int);
};
//employee.cpp
#include <iostream>
#include <cstring>
#include "employee.h"
using namespace std;
int employee::employeeno=1000;
employee::employee()
{
individualempno=employeeno++;
grade=1;
accumpay=0.0;}
employee::~employee()
{}
void employee::promote(int increment)
{ grade+=increment;}
void employee::setname(char* names)
{ strcpy(name,names);}
char* employee::getname()
{ return name;}
int employee::getindividualempno()
{ return individualempno;}
int employee::getgrade()
{ return grade;}
float employee::getaccumpay()
{ return accumpay;}
technician::technician()
{ hourlyrate=100;}
void technician::pay()
{ accumpay=hourlyrate*workhours;
}
void technician::promote(int)
{ employee::promote(2);}
salesman::salesman()
{ commrate = 0.04 ;}
void salesman::setsales(float sl)
{ sales=sl;}
void salesman::promote(int)
{ employee::promote(0);}
manager::manager()
{ monthlypay=8000;}
void manager::pay()
{ accumpay=monthlypay;}
void manager::promote(int)
{ employee::promote(3);}
salesmanager::salesmanager()
{ monthlypay=5000; commrate = 0.005;}
void salesmanager::pay()
{ accumpay=monthlypay+commrate*sales;
}
void salesmanager::promote(int)
{ employee::promote(2);}
//10_16.cpp
#include <iostream>
#include "employee.h"
#include <vector>
using namespace std;
int main()
{
manager m1;
technician t1;
salesmanager sm1;
salesman s1;
char namestr[20];
vector <employee *> vchar;
vchar.push_back(&m1);
vchar.push_back(&t1);
vchar.push_back(&sm1);
vchar.push_back(&s1);
int i;
for (i=0;i<4;i++)
{
cout<<"请输入下一个雇员的名字:";
cin>>namestr;
vchar[i]->setname(namestr);
vchar[i]->promote();
}
cout<<"请输入兼职技术人员"<<t1.getname()<<"本月的工作时数";
int ww;
cin>>ww;
t1.setworkhours(ww);
cout<<"请输入销售经理"<<sm1.getname()<<"所管辖销售总额";
float sl;
cin>>sl;
sm1.setsales(sl);
cout<<"请输入销售员"<<sm1.getname()<<"销售额";
cin>>sl;
s1.setsales(sl);
for (i=0;i<4;i++)
{
vchar[i]->pay();
cout<<vchar[i]->getname()<<"编号"<<vchar[i]->getindividualempno()
<<"级别为"
<<vchar[i]->getgrade()<<"级,本月工资"<<vchar[i]->getaccumpay()<<endl;
}
}