下面的程序,就出了一点错,不知在哪,求救了!
#include<iostream.h>
#include<string.h>
class employee
{//基类
private:
char * num;
char * name;
//float salary;
public:
employee()
{
num=0;
name=0;
//salary=0;
}
employee(char * num1,char * name1 )
{
num= new char[4];
strcpy(num,num1);
name=new char [strlen(name1)+1];
strcpy(name,name1);
//salary=salary1;
}
~employee()
{
delete [] num;
delete [] name;
}
void print()const
{
cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
//cout<<"salary:"<<salary<<endl;
}
};
class part:public virtual employee
{ //兼职技术员
private:
int hour;
float salary;
public:
part(char * num1,char *name1,int h)
:employee(num1,name1)
{
hour=h;
salary=float(100*hour);
}
void print()const
{
employee::print();
cout<<"position:"<<"part(兼职技术员)"<<endl;
cout<<"salary:"<<salary<<endl<<endl;
}
};
class sales :public virtual employee
{//销售员
private:
int amount;
float salary;
public:
sales(char * num1,char * name1,int am)
:employee(num1,name1)
{
amount=am;
salary=float(0.4*amount);
}
void print()const
{
employee::print();
cout<<"position:"<<"sales(销售员)"<<endl;
cout<<"salary:"<<salary<<endl<<endl;
}
};
class manager : public virtual employee
{//经理
private:
float salary;
public:
manager(char *num1,char * name1,float salary1)
:employee(num1,name1)
{
salary=8000;
}
void print()const
{
employee::print();
cout<<"position:"<<"manager(经理)"<<endl;
cout<<"salary:"<<salary<<endl<<endl;
}
};
////////这是出问题的地方
class salemanager :public sales,public manager
{//销售经理
private:
float salary;
int totalamount;
int am1;
float salary1;
public:
salemanager(char * num1,char * name1,int tamount,
int am,float salary2)
:sales(num1,name1,am),manager(num1,name1,salary2)
{
am1=am;
salary1=salary2;
totalamount=tamount;
salary=float(5000+0.04*totalamount);
}
void print()const
{
employee::print();
cout<<"position:"<<"salemanager(销售经理)"<<endl;
cout<<"salary:"<<salary<<endl<<endl;
}
};
void main()
{
manager m1("001","li",80);
m1.print();
sales s1("002","liu",5000);
s1.print ();
part p1("003","wang",20);
p1.print ();
salemanager sm1("004","hu",10000,0,0);
sm1.print ();
}