Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2341713
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:05:36

#include
#include
class employee{
protected:
char *name,sex;
int grade;
double accumpay;
int employeeNo;
public:
employee(char *n,char s,int g, int eN){
name=new char[strlen(n)+1];
strcpy(name,n);
sex=s;
grade=g;
employeeNo=eN;
}
virtual ~employee(){
delete []name;
}
virtual void pay()=0;
virtual void displaystatus(){
cout<<"\n name:"< cout<<"-sex:"< cout<<"-grade:"< cout<<"-employeeNo:"< }
};
class technician:public employee{
private:
float HourRate;
int WorkHours;
public:
technician(char *n,char s,int g, int eN,int w,float h=100.0):employee(n,s,g,eN
){
HourRate=h;
WorkHours=w;
}
     void  displaystatus() {
employee::displaystatus() ;
cout<<"-HourRate:"< cout<<"-WorkHours:"<}
void pay(){
accumpay=HourRate*WorkHours;
cout<<"Technician's salary is:"<}
};
class salesman:virtual public employee{
protected:
double commRate;
float sales;
public:
      salesman(char *n,char s,int g,int eN,float sa,double c=0.04):employee(n,s
,g,eN){
commRate=c;
sales=sa;
}
void pay(){
accumpay=commRate*sales;
cout<<"Salesman's salary is:"<}
void displaystatus(){
employee::displaystatus() ;
cout<<"-commRate:"< cout<<"-sales:"<
}
};
class manager:virtual public employee{
protected:
float monthlypay;
public:
manager(char *n,char s,int g,int eN,float m=8000):employee(n,s,g,eN){
monthlypay=m;
}
void pay(){
accumpay=monthlypay;
cout<<"manager's salary is:"<}
void diaplaystatus(){
employee::displaystatus() ;
cout<<"-monthlypay:"<}
};
class salesmanager: public manager, public salesman{
public:
salesmanager(char *n,char s,int g, int eN,float sa,float m=5000,double c=0.005)
:manager(n,s,g,eN,m),salesman(n,s,g,eN,sa,c){}
void pay(){
accumpay=monthlypay+commRate*sales;
cout<<"salesmanager's salary is: "<}
void displaystatus(){
manager::displaystatus() ;
salesman::displaystatus ();
}
};
void main(){
employee *p;
technician zh("zhang",'m',3,1001,40,100.0);
salesman   li("lifu",'f',1,1002,80000.0,0.04);
manager    ch("chen",'m',3,1003,8000.0);
salesmanager y("yang",'f',3,1004,400000.0,5000,0.005);
p=&zh;
    p->pay();
cout< p->displaystatus();
cout< p=&li;
p->pay();
cout< p->displaystatus();
    cout< p=&ch;
p->pay();
cout< p->displaystatus();
cout< p=&y;
p ->pay();
p->displaystatus();
cout<<"OK!"<}
此程序有这么一个错误,请求高手帮助!!!!小弟在线等''
C:\Program Files\Microsoft Visual Studio\MyProjects\e\f.cpp(87) : error C2512: 'employee::employee' : no appropriate default constructor available



--------------------next---------------------

阅读(1105) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~