标题:[求助]问题出在哪
只看楼主
bluebell
Rank: 1
等 级:新手上路
帖 子:102
专家分:0
注 册:2007-5-14
 问题点数:0 回复次数:1 
[求助]问题出在哪

下面的程序,就出了一点错,不知在哪,求救了!

#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 ();
}

搜索更多相关主题的帖子: employee private include public 
2007-07-12 21:21
zz_tot
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2007-7-4
得分:0 
把类 salemanager
void print()const
{
employee::print();
cout<<"position:"<<"salemanager(销售经理)"<<endl;
cout<<"salary:"<<salary<<endl<<endl;
}
中的 employee::print();
注释掉 就没有问题了
2007-07-13 11:04



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-154954-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.189107 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved