高手帮我找下错

kingreat 2007-05-24 09:21:24
#include"iostream.h"
#include"string.h"
class EmpSalary//定义工资类
{
public:
float Wage;
float Subsidy;
float Rent;
float CostOfElec;
float CostOfWater;
float RealSum(){return Wage+Subsidy-Rent-CostOfElec-CostOfWater;}
};
enum Position
{
MANAGER,
ENGINEER,
EMPLOYEE,
WORKER
};
class Date
{
int day,month,year;
public:
void init(int,int,int);
void print_ymd();
};
class Employee
{
string Department;
string Name;
Date Birthdate;
Position EmpPosition;
Date DateOfWork;
EmpSalary Salary;
public:
void Register(string Depart,string nName,Date tBirthdate,Position nPosoition,Date tDateOfWork);
void SetSalary(float wage,float subsidy,float rent,float elec,float water);
float GetSalary();
void ShowMessage();
};
void Date::init(int yy,int mm,int dd)
{
month=(mm>=1&&mm<=12)?mm:1;
year=(yy>=1990&&yy<=2100)?yy:1900;
day=(dd>=1&&dd<=31)?dd:1;
}
void Date::print_ymd()
{
cout<<year<<"-"<<month<<"-"<<day<<endl;
}
void Employee::Register(string Depart,string nName,Date tBirthdate,Posotion nPosition,Date tDateOfWork)
{
Department=Depart;
Name=nName;
Birthdate=tBirthdate;
EmpPosition=nPosition;
DateOfWork=tDateOfWork;
}
void Employee::SetSalary(float wage,float subsidy,float rent,float elec,float water)
{
Salary.Wage=wage;
Salary.Subsidy=subsidy;
Salary.Rent=rent;
Salary.CostOfElec=elec;
Salary.CostOfWater=water;
}
float Employee::GetSalary()
{
return Salary.RealSum();
}
void Employee::ShowMessage()
{
cout<<"Depart:"<<Department<<endl;
cout<<"Name:"<<Name<<endl;
cout<<"Birthdate:";
Birthdate.print_ymd();
switch(EmpPosition)
{
case MANAGER:
cout<<"Position:"<<"MANAGER"<<endl; break;
case ENGINEER:
cout<<"Position:"<<"ENGINEER"<<endl; break;
case EMPLOYEE:
cout<<"Position:"<<"EMPLOYEE"<<endl; break;
case WORKER:
cout<<"Position:"<<"WORKER"<<endl; break;

}
cout<<"Date of Work:";
DateOfWork.print_ymd();
cout<<"Salary:"<<GetSalary()<<endl;
cout<<"----------"<<endl;
}
#define MAX_EMPLOYEE 100
void main()
{
Employee EmployeeList[MAX_EMPLOYEE];
int EmpCount=0;
Date birthdate,workdate;
birthdate.init(1980,5,3);
workdate.init(1999,7,20);
EmployeeList[EmpCount].Register("项目部","张弓长",birthdate,ENGINEER,workdate);
EmployeeList[EmpCount].SetSalary(1000,200,100,50,20);
EmpCount++;
birthdate.init(1979,4,8);
workdate.init(2002,3,1);
EmployeeList[EmpCount].Register("项目部","李木子",birthdate,MANAGER,workdate);
EmployeeList[Employee].SetSalary(1500,200,150,50,20);
EmpCount++;
for(int i=0;i<EmpCount;i++)
EmployeeList[i].ShowMessage();
}
...全文
152 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
kingreat 2007-05-24
  • 打赏
  • 举报
回复
#include"iostream"
#include"string"
using namespace std;
class EmpSalary//定义工资类
{
public:
float Wage;
float Subsidy;
float Rent;
float CostOfElec;
float CostOfWater;
float RealSum(){return Wage+Subsidy-Rent-CostOfElec-CostOfWater;}
};
enum Position
{
MANAGER,
ENGINEER,
EMPLOYEE,
WORKER
};
class Date
{
int day,month,year;
public:
void init(int,int,int);
void print_ymd();
};
class Employee
{
string Department;
string Name;
Date Birthdate;
Position EmpPosition;
Date DateOfWork;
EmpSalary Salary;
public:
void Register(string Depart,string nName,Date tBirthdate,Position nPosition,Date tDateOfWork);
void SetSalary(float wage,float subsidy,float rent,float elec,float water);
float GetSalary();
void ShowMessage();
};
void Date::init(int yy,int mm,int dd)
{
month=(mm>=1&&mm<=12)?mm:1;
year=(yy>=1900&&yy<=2100)?yy:1900;
day=(dd>=1&&dd<=31)?dd:1;
}
void Date::print_ymd()
{
cout<<year<<"-"<<month<<"-"<<day<<endl;
}
void Employee::Register(string Depart,string nName,Date tBirthdate,Position nPosition,Date tDateOfWork)
{
Department=Depart;
Name=nName;
Birthdate=tBirthdate;
EmpPosition=nPosition;
DateOfWork=tDateOfWork;
}
void Employee::SetSalary(float wage,float subsidy,float rent,float elec,float water)
{
Salary.Wage=wage;
Salary.Subsidy=subsidy;
Salary.Rent=rent;
Salary.CostOfElec=elec;
Salary.CostOfWater=water;
}
float Employee::GetSalary()
{
return Salary.RealSum();
}
void Employee::ShowMessage()
{
cout<<"Depart:"<<Department<<endl;
cout<<"Name:"<<Name<<endl;
cout<<"Birthdate:";
Birthdate.print_ymd();
switch(EmpPosition)
{
case MANAGER:
cout<<"Position:"<<"MANAGER"<<endl; break;
case ENGINEER:
cout<<"Position:"<<"ENGINEER"<<endl; break;
case EMPLOYEE:
cout<<"Position:"<<"EMPLOYEE"<<endl; break;
case WORKER:
cout<<"Position:"<<"WORKER"<<endl; break;

}
cout<<"Date of Work:";
DateOfWork.print_ymd();
cout<<"Salary:"<<GetSalary()<<endl;
cout<<"----------"<<endl;
}
#define MAX_EMPLOYEE 100
void main()
{
Employee EmployeeList[MAX_EMPLOYEE];
int EmpCount=0;
Date birthdate,workdate;
birthdate.init(1980,5,3);
workdate.init(1999,7,20);
EmployeeList[EmpCount].Register("销售部","张弓长",birthdate,ENGINEER,workdate);
EmployeeList[EmpCount].SetSalary(1000,200,100,50,20);
EmpCount++;
birthdate.init(1979,4,8);
workdate.init(2002,3,1);
EmployeeList[EmpCount].Register("项目部","李木子",birthdate,MANAGER,workdate);
EmployeeList[EmpCount].SetSalary(1500,200,150,50,20);
EmpCount++;
for(int i=0;i<EmpCount;i++)
EmployeeList[i].ShowMessage();
}
granterfwj 2007-05-24
  • 打赏
  • 举报
回复
#include"iostream"
#include"string"
using namespace std;
class EmpSalary//定义工资类
{
public:
float Wage;
float Subsidy;
float Rent;
float CostOfElec;
float CostOfWater;
float RealSum(){return Wage+Subsidy-Rent-CostOfElec-CostOfWater;}
};
enum Position
{
MANAGER,
ENGINEER,
EMPLOYEE,
WORKER
};
class Date
{
int day,month,year;
public:
void init(int,int,int);
void print_ymd();
};
class Employee
{
protected:
string Department;
string Name;
Date Birthdate;
Position EmpPosition;
Date DateOfWork;
EmpSalary Salary;
public:
void Register(string Depart,string nName,Date tBirthdate,Position nPosoition,Date tDateOfWork);
void SetSalary(float wage,float subsidy,float rent,float elec,float water);
float GetSalary();
void ShowMessage();
};
void Date::init(int yy,int mm,int dd)
{
month=(mm>=1&&mm<=12)?mm:1;
year=(yy>=1990&&yy<=2100)?yy:1900;
day=(dd>=1&&dd<=31)?dd:1;
}
void Date::print_ymd()
{
cout<<year<<"-"<<month<<"-"<<day<<endl;
}
void Employee::Register(string Depart,string nName,Date tBirthdate,Position nPosition,Date tDateOfWork)
{
Department=Depart;
Name=nName;
Birthdate=tBirthdate;
EmpPosition=nPosition;
DateOfWork=tDateOfWork;
}
void Employee::SetSalary(float wage,float subsidy,float rent,float elec,float water)
{
Salary.Wage=wage;
Salary.Subsidy=subsidy;
Salary.Rent=rent;
Salary.CostOfElec=elec;
Salary.CostOfWater=water;
}
float Employee::GetSalary()
{
return Salary.RealSum();
}
void Employee::ShowMessage()
{
cout<<"Depart:"<<Department<<endl;
cout<<"Name:"<<Name<<endl;
cout<<"Birthdate:";
Birthdate.print_ymd();
switch(EmpPosition)
{
case MANAGER:
cout<<"Position:"<<"MANAGER"<<endl; break;
case ENGINEER:
cout<<"Position:"<<"ENGINEER"<<endl; break;
case EMPLOYEE:
cout<<"Position:"<<"EMPLOYEE"<<endl; break;
case WORKER:
cout<<"Position:"<<"WORKER"<<endl; break;

}
cout<<"Date of Work:";
DateOfWork.print_ymd();
cout<<"Salary:"<<GetSalary()<<endl;
cout<<"----------"<<endl;
}
#define MAX_EMPLOYEE 100
void main()
{
Employee EmployeeList[MAX_EMPLOYEE];
int EmpCount=0;
Date birthdate,workdate;
birthdate.init(1980,5,3);
workdate.init(1999,7,20);
EmployeeList[EmpCount].Register("项目部","张弓长",birthdate,ENGINEER,workdate);
EmployeeList[EmpCount].SetSalary(1000,200,100,50,20);
EmpCount++;
birthdate.init(1979,4,8);
workdate.init(2002,3,1);
EmployeeList[MAX_EMPLOYEE].Register("项目部","李木子",birthdate,MANAGER,workdate);
EmployeeList[MAX_EMPLOYEE].SetSalary(1500,200,150,50,20);
EmpCount++;
for(int i=0;i<EmpCount;i++)
EmployeeList[i].ShowMessage();
}
我改后的程序
好象还有点问题
仅供参考
反正编译没问题了
parrylau 2007-05-24
  • 打赏
  • 举报
回复

改了一地主,string.h里的string 类不知你是怎么定义的?
parrylau 2007-05-24
  • 打赏
  • 举报
回复
#include"iostream.h"
class string
{
public:
protected:
private:
};
class EmpSalary//定义工资类
{
public:
float Wage;
float Subsidy;
float Rent;
float CostOfElec;
float CostOfWater;
float RealSum(){return Wage+Subsidy-Rent-CostOfElec-CostOfWater;}
};
enum Position
{
MANAGER,
ENGINEER,
EMPLOYEE,
WORKER
};
class Date
{
int day,month,year;
public:
void init(int,int,int);
void print_ymd();
};
class Employee
{
string Department;
string Name;
Date Birthdate;
Position EmpPosition;
Date DateOfWork;
EmpSalary Salary;
public:
void Register(string Depart,string nName,Date tBirthdate,Position nPosoition,Date tDateOfWork);
void SetSalary(float wage,float subsidy,float rent,float elec,float water);
float GetSalary();
void ShowMessage();
};
void Date::init(int yy,int mm,int dd)
{
month=(mm>=1&&mm<=12)?mm:1;
year=(yy>=1990&&yy<=2100)?yy:1900;
day=(dd>=1&&dd<=31)?dd:1;
}
void Date::print_ymd()
{
cout<<year<<"-"<<month<<"-"<<day<<endl;
}
void Employee::Register(string Depart,string nName,Date tBirthdate,Position nPosition,Date tDateOfWork)
{
Department=Depart;
Name=nName;
Birthdate=tBirthdate;
EmpPosition=nPosition;
DateOfWork=tDateOfWork;
}
void Employee::SetSalary(float wage,float subsidy,float rent,float elec,float water)
{
Salary.Wage=wage;
Salary.Subsidy=subsidy;
Salary.Rent=rent;
Salary.CostOfElec=elec;
Salary.CostOfWater=water;
}
float Employee::GetSalary()
{
return Salary.RealSum();
}
void Employee::ShowMessage()
{
cout<<"Depart:"<<Department<<endl;
cout<<"Name:"<<Name<<endl;
cout<<"Birthdate:";
Birthdate.print_ymd();
switch(EmpPosition)
{
case MANAGER:
cout<<"Position:"<<"MANAGER"<<endl; break;
case ENGINEER:
cout<<"Position:"<<"ENGINEER"<<endl; break;
case EMPLOYEE:
cout<<"Position:"<<"EMPLOYEE"<<endl; break;
case WORKER:
cout<<"Position:"<<"WORKER"<<endl; break;

}
cout<<"Date of Work:";
DateOfWork.print_ymd();
cout<<"Salary:"<<GetSalary()<<endl;
cout<<"----------"<<endl;
}
#define MAX_EMPLOYEE 100
void main()
{
Employee EmployeeList[MAX_EMPLOYEE];
int EmpCount=0;
Date birthdate,workdate;
birthdate.init(1980,5,3);
workdate.init(1999,7,20);
EmployeeList[EmpCount].Register(string("项目部"),string("张弓长"),birthdate,ENGINEER,workdate);
EmployeeList[EmpCount].SetSalary(1000,200,100,50,20);
EmpCount++;
birthdate.init(1979,4,8);
workdate.init(2002,3,1);
EmployeeList[EmpCount].Register("项目部","李木子",birthdate,MANAGER,workdate);
EmployeeList[Employee].SetSalary(1500,200,150,50,20);
EmpCount++;
for(int i=0;i<EmpCount;i++)
EmployeeList[i].ShowMessage();
}
parrylau 2007-05-24
  • 打赏
  • 举报
回复
把string.h发上来,不然,有些地方改不到
freshui 2007-05-24
  • 打赏
  • 举报
回复
太长了 手上还没有编译器 :)
Sco_field 2007-05-24
  • 打赏
  • 举报
回复
给点错误提示先~

lx上
星羽 2007-05-24
  • 打赏
  • 举报
回复
有点晕

lx上

64,647

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧