执行 cl.exe 时出错!C++高手帮我看看那里出错呀,帮忙改过来!谢谢

hunxiao 2008-12-31 10:03:32
#include<iostream.h>
#include<stdlib.h>
#include<fstream.h>
#include<iomanip.h>
#include<string.h>
class employee
{
public:
employee()
{
salary=0;
}
void pay(){}
void print(){}
void input()
{
cout<<"ID:";
cin>>no;
cout<<" NAME:";
cin>>name;
cout<<" SEX(m/w):";
cin>>sex;
cout<<" AGE:";
cin>>age;
}
protected:
int no;
char name[8];
float salary;
char sex;
int age;

};
class manager:virtual public employee
{
protected:
float monthlypay,sale;
public:
manager(){monthlypay=8000;}
void input(){cout<<"Manger";employee::input();}
void save()
{
fstream outfile;
outfile.open("f:flsdfj.txt",ios::app);
if(!outfile)
{
cout<<"f can't open.\n";
abort();
}
outfile<<"Manger"<<endl;
outfile<<"ID"<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<"SALARY"<<salary<<endl;
}
void pay(){salary=monthlypay;}
void print()
{
cout<<"├─────┼─────┼─────┼─────┼─────┤"<<endl;
cout<<"│"<<setw(10)<<no<<"│"<<setw(10)<<name<<"│"<<setw(10)<<sex\
<<"│"<<setw(10)<<age<<"│"<<setw(10)<<salary<<"│"<<endl;
}
};

class technician:virtual public employee
{
private:
float hourlyrate;
int workhours;
public:
technician(){hourlyrate=100;}
void pay()
{
cout<<name<<"Work hour:";
cin>>workhours;
salary=hourlyrate*workhours;
}
void input(){cout<<"TECHNICIAN"<<endl;employee::input();}
void save()
{
fstream outfile;
outfile.open("f:flsdfj.txt",ios::app);
if(!outfile)
{
cout<<"f can't open.\n";
abort();
}
outfile<<"TECHNICIAN"<<endl;
outfile<<"ID"<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<"SALARY"<<salary<<endl;
}
void print()
{
cout<<"├─────┼─────┼─────┼─────┼─────┤"<<endl;
cout<<"│"<<setw(10)<<no<<"│"<<setw(10)<<name<<"│"<<setw(10)<<sex\
<<"│"<<setw(10)<<age<<"│"<<setw(10)<<salary<<"│"<<endl;
}
};
class salesman:virtual public employee
{
protected:
float commrate;
float sales;
public:
salesman(){commrate=0.04;}
void input(){cout<<"SALEMAN";employee::input();}
void save()
{
fstream outfile;
outfile.open("f:flsdfj.txt",ios::app);
if(!outfile)
{
cout<<"f can't open.\n";
abort();
}
outfile<<"TECHNICIAN"<<endl;
outfile<<"ID"<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<"SALARY"<<salary<<endl;
}
void pay()
{
cout<<name<<"Sales volume:";
cin>>sales;
salary=sales*commrate;
}
void print()
{
cout<<"├─────┼─────┼─────┼─────┼─────┤"<<endl;
cout<<"│"<<setw(10)<<no<<"│"<<setw(10)<<name<<"│"<<setw(10)\
<<sex<<"│"<<setw(10)<<age<<"│"<<setw(10)<<salary<<"│"<<endl;
}
};

...全文
905 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
funnybunny 2008-12-31
  • 打赏
  • 举报
回复
LZ玩的是传说中的找茬...?眼花了...
hunxiao 2008-12-31
  • 打赏
  • 举报
回复
class salesmanager:virtual public manager,virtual public salesman
{
private:
float total;int no1,no2,no3,no4;char name1[8],name2[8],name3[8],name4[8];
float sale1,sale2,sale3,sale4;
public:
void salemanager()
{
monthlypay=5000;
commrate=0.005;
}
void input(){cout<<"Sales manger";employee::input();}
void save()
{
fstream outfile;
outfile.open("f:flsdfj.txt",ios::app);
if(!outfile)
{
cout<<"f can't open.\n";
abort();
}
outfile<<"Sales manger"<<endl;
outfile<<"ID"<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<"SALARY"<<salary<<endl;
}
void savesale()
{
fstream outfile;
outfile.open("f:flsdfj.txt",ios::app);
if(!outfile)
{
cout<<"f can't open.\n";
abort();
}
outfile<<"The salary of saleman of sales manger and themselves"<<endl;
outfile<<"ID"<<no1<<"NAME"<<name1<<"SALARY"<<sale1<<endl;
outfile<<"ID"<<no2<<"NAME"<<name2<<"SALARY"<<sale2<<endl;
outfile<<"ID"<<no3<<"NAME"<<name3<<"SALARY"<<sale3<<endl;
outfile<<"ID"<<no4<<"NAME"<<name4<<"SALARY"<<sale4<<endl;
}
void pay()
{
cout<<name<<"The sales volume of everydepartment:";
salary=monthlypay+commrate*total;
}
float totalsale(){total=sale1+sale2+sale3+sale4;return total;}
void printtotal()
{
cout<<"├─────┴──┬──┴─────┤"<<endl;
cout<<"│Total   │   "<<setw(10)<<total<<" │"<<endl;
cout<<"└────────┴────────┘"<<endl;
}
void sort(salesmanager p)
{
int tmp,i,j;
for(j=0;j<2;j++)
for(i=0;i<2;i++)
if(total<p.salary)
{
tmp=salary;
total=p.salary;
p.salary=tmp;
tmp=no;
no=p.no;
p.no=tmp;
}
}
void saler()
{
cout<<"Staff ID:";
cin>>no1;
cout<<" Staff NAME:";
cin>>name1;
cout<<" Sales volume:";
cin>>sale1;
cout<<"Staff ID:";
cin>>no2;
cout<<" Staff NAME:";
cin>>name2;
cout<<" Sales volume:";
cin>>sale2;
cout<<"Staff ID:";
cin>>no3;
cout<<" Staff NAME:";
cin>>name3;
cout<<" Sales volume:";
cin>>sale3;
cout<<"Staff ID:";
cin>>no4;
cout<<" Staff NAME:";
cin>>name4;
cout<<" Sales volume:";
cin>>sale4;

}
void saleprint()
{
cout<<"│"<<setw(10)<<no1<<"│"<<setw(10)<<name1<<"│"<<setw(10)<<sale1<<"│"<<endl;
cout<<"├─────┼─────┼─────┤"<<endl;
cout<<"│"<<setw(10)<<no2<<"│"<<setw(10)<<name2<<"│"<<setw(10)<<sale2<<"│"<<endl;
cout<<"├─────┼─────┼─────┤"<<endl;
cout<<"│"<<setw(10)<<no3<<"│"<<setw(10)<<name3<<"│"<<setw(10)<<sale3<<"│"<<endl;
cout<<"├─────┼─────┼─────┤"<<endl;
cout<<"│"<<setw(10)<<no4<<"│"<<setw(10)<<name4<<"│"<<setw(10)<<sale4<<"│"<<endl;
}
void print()
{
cout<<"├─────┼─────┼─────┼─────┼─────┤"<<endl;
cout<<"│"<<setw(10)<<no<<"│"<<setw(10)<<name<<"│"<<setw(10)<<sex<<"│"\
<<setw(10)<<age<<"│"<<setw(10)<<salary<<"│"<<endl;
}
};
void main()
{
manager m[4];
technician t[4];
salesman s[4];
salesmanager sm[4];
t[1].save();
int flag=1,operate;
do{
cout<<" #### The system of salary manger ####\n";
cout<<" ┌─────────────┐\n";
cout<<" │ Chose your actions │\n";
cout<<" │ Input:1,Enter │\n";
cout<<" │ Total:2,Enter │\n";
cout<<" │ Output:3,Enter │\n";
cout<<" │ Save:4,Enter │\n";
cout<<" │ Exit:5,Enter │\n";
cout<<" └─────────────┘\n";
cout<<" Please chose one action: ";
cin>>operate;
switch(operate)
{
case 1:
cout<<"Waiting for a minute!"<<endl;
{
for(int i=0;i<4;i++)
{m[i].input();}
for(int j=0;j<4;j++)
{t[j].input();}
for(int k=0;k<4;k++)
{s[k].input();}
for(int l=0;l<4;l++)
{sm[l].input();}
};
{
for(int i=0;i<4;i++)
{m[i].pay();}
for(int j=0;j<4;j++)
{t[j].pay();}
for(int k=0;k<4;k++)
{s[k].pay();}
for(int l=0;l<4;l++)
{sm[l].pay();sm[l].saler();}
};break;
case 2:
cout<<"Waiting for a minute!"<<endl;
{
{
for(int l=0;l<4;l++)
sm[l].totalsale();
for(int i=0;i<4;i++)
for(int j=0;j<2;j++)
sm[j].sort(sm[j+1]);
};
cout<<"The saleman of the first sales manger"<<endl;
cout<<"┌─────┬─────┬─────┐"<<endl;
cout<<"│ ID  │  NAME  │ SALARY │"<<endl;
sm[0].saleprint();
sm[0].printtotal();
cout<<" The order is complete"<<endl;
cout<<"List names of every sales manger"<<endl;
cout<<"┌─────┬─────┬─────┬─────┬─────┐"<<endl;
cout<<"│ ID  │  NAME  │ SEX   │ AGE   │ SALARY  │"<<endl;
for(int k=0;k<4;k++)
sm[k].print();
cout<<"└─────┴─────┴─────┴─────┴─────┘"<<endl;
};break;
case 3:
cout<<"Waiting for a minute!"<<endl;
{
cout<<" The blank of the :"<<endl;
cout<<"┌─────┬─────┬─────┬─────┬─────┐"<<endl;
cout<<"│ ID  │  NAME  │ SEX   │ AGE   │ SALARY  │"<<endl;
for(int i=0;i<4;i++)
{m[i].print();}
cout<<"└─────┴─────┴─────┴─────┴─────┘"<<endl;
cout<<"┌─────┬─────┬─────┬─────┬─────┐"<<endl;
cout<<"└─────┴─────┴─────┴─────┴─────┘"<<endl;
cout<<"┌─────┬─────┬─────┬─────┬─────┐"<<endl;
cout<<"│ ID  │  NAME  │ SEX   │ AGE   │ SALARY  │"<<endl;
for(int k=0;k<4;k++)
{s[k].print();}
cout<<"└─────┴─────┴─────┴─────┴─────┘"<<endl;
cout<<"┌─────┬─────┬─────┬─────┬─────┐"<<endl;
cout<<"└─────┴─────┴─────┴─────┴─────┘"<<endl;
};break;
case 4:
cout<<"Waiting for a minute!"<<endl;
{
for(int i=0;i<4;i++)
{m[i].save();}
for(int j=0;j<4;j++)
{t[j].save();}
for(int k=0;k<4;k++)
{s[k].save();}
for(int l=0;l<4;l++)
{sm[l].save();}
};cout<<" Information save! "<<endl;break;
case 5:exit(0);break;
default:cout<<"Error!Repeat again!"<<endl;
}
}while(flag=1);
}
}
编译结果是:--------------------Configuration: llp1 - Win32 Debug--------------------
Compiling...
llp1.cpp
d:\我的文档\cc++\llp1.cpp(101) : warning C4305: '=' : truncation from 'const double' to 'float'
d:\我的文档\cc++\llp1.cpp(138) : warning C4305: '=' : truncation from 'const double' to 'float'
d:\我的文档\cc++\llp1.cpp(187) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
d:\我的文档\cc++\llp1.cpp(189) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
d:\我的文档\cc++\llp1.cpp(343) : error C2143: syntax error : missing ';' before '}'
d:\我的文档\cc++\llp1.cpp(343) : error C2143: syntax error : missing ';' before '}'
d:\我的文档\cc++\llp1.cpp(343) : error C2143: syntax error : missing ';' before '}'
执行 cl.exe 时出错.

llp1.obj - 1 error(s), 0 warning(s)

64,641

社区成员

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

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