这是调式时出的错误.docx
- 文档编号:23811886
- 上传时间:2023-05-21
- 格式:DOCX
- 页数:18
- 大小:17.89KB
这是调式时出的错误.docx
《这是调式时出的错误.docx》由会员分享,可在线阅读,更多相关《这是调式时出的错误.docx(18页珍藏版)》请在冰豆网上搜索。
这是调式时出的错误
这是调式时出的错误:
我用不同颜色标出来了标示红色的地方是系统显示有错误的地方。
下面给出的是错误:
Configuration:
Cpp1-Win32Debug--------------------
Compiling...
Cpp1.cpp
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(104):
errorC2664:
'strcmp':
cannotconvertparameter1from'int'to'constchar*'
Conversionfromintegraltypetopointertyperequiresreinterpret_cast,C-stylecastorfunction-stylecast
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(254):
errorC2039:
'Tongji':
isnotamemberof'Staffmassage'
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(54):
seedeclarationof'Staffmassage'
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(264):
errorC2065:
'Head':
undeclaredidentifier
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(264):
errorC2440:
'=':
cannotconvertfrom'int'to'classStaff*'
Conversionfromintegraltypetopointertyperequiresreinterpret_cast,C-stylecastorfunction-stylecast
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(268):
errorC2039:
'Final_Salary':
isnotamemberof'Staff'
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(8):
seedeclarationof'Staff'
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(270):
errorC2039:
'next':
isnotamemberof'Staff'
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(8):
seedeclarationof'Staff'
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(287):
errorC2059:
syntaxerror:
':
'
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(289):
errorC2143:
syntaxerror:
missing';'before'{'
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(292):
errorC2039:
'next':
isnotamemberof'Staff'
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(8):
seedeclarationof'Staff'
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(292):
errorC2065:
'head':
undeclaredidentifier
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(293):
errorC2440:
'=':
cannotconvertfrom'classStaff*'to'int'
Thisconversionrequiresareinterpret_cast,aC-stylecastorfunction-stylecast
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(296):
errorC2227:
leftof'->next'mustpointtoclass/struct/union
c:
\documentsandsettings\administrator\mydocuments\cpp1.cpp(296):
fatalerrorC1903:
unabletorecoverfrompreviouserror(s);stoppingcompilation
执行cl.exe时出错.
Cpp1.obj-1error(s),0warning(s)
#include
#include
#include
#include
usingnamespacestd;
//********Staff类**********1
classStaff
{
public:
charname[10];//姓名
intnumber;//卡号
intmonth;//月份
floatSPWages;//应发工资
floatAPWages;//实发工资
floatWater;//水费
floatElectrical;//电费
floatTax;//税金
Staff*Next;
voidInput()
{
cout<<"\t\t请输入职工的姓名:
";cin>>name;
cout<<"\t\t请输入职工的卡号:
";cin>>number;
cout<<"\t\t请输入应发工资:
";cin>>SPWages;
while(SPWages<0)
{cout<<"输入错误!
请重新输入…"< cout<<"\t\t请输入应发工资: ";cin>>SPWages; } cout<<"\t\t请输入水费: ";cin>>Water; while(Water<0) {cout<<"输入错误! 请重新输入…! "< cout<<"\t\t请输入水费: ";cin>>Water; } cout<<"\t\t请输入电费: ";cin>>Electrical; while(Electrical<0) {cout<<"输入错误! 请重新输入…! "< cout<<"\t\t请输入电费: ";cin>>Electrical; } } voidReadFile(istream&in) { in>>name>>number>>SPWages>>APWages>>Water>>Electrical; } voidShow() {if(SPWages<=800)Tax=0; if((SPWages>800.0)&&(SPWages<1400.0))Tax=(SPWages-800)*0.05; if(SPWages>1400){Tax=(SPWages-1400)*0.1;} APWages=SPWages-Water-Electrical-Tax; cout<<"姓名: "< "< "< <<"水费: "< "< "< } }; //********Staffmassage类*********2 classStaffmassage { public: Staffmassage(); ~Staffmassage(); voidShowMenu(); voidFind();//查找 voidSave();//保存 voidModifyItem(); voidRemoveItem(); voidDisplay() { intsize[1]; cout<<"请指定显示的条目数单位"< cin>>size[0]; inti; for(Staff*p=Head->Next;p! =End;p=p->Next){ p->Show(); i++; if(i>=size[0]){ cout<<"请继续……"; getch(); i=0; } } } voidAddItem() { End->Input(); End->Next=newStaff; End=End->Next; cout<<"添加成功! "< cout<<"请继续……"; getch(); } private: //查找模块 Staff*Head,*End; ifstreamin; ofstreamout; Staff*FindItem(char*name) { for(Staff*p=Head;p->Next! =End;p=p->Next)//匹配成功则返回上一个指针,不成功就返回空 if(! strcmp(p->Next->name,name))returnp; returnNULL; } Staff*Findnumber(char*number) { for(Staff*p=Head;p->Next! =End;p=p->Next)//匹配成功则返回上一个指针,不成功就返回空 if(! strcmp(p->Next->number,number))returnp; returnNULL; } }; //*********构造函数*********3 Staffmassage: : Staffmassage() { Head=newStaff; Head->Next=newStaff; End=Head->Next; in.open("sort.txt"); if(! in) cout<<"新系统! 请先输入。 "< else { while(! in.eof()) { End->ReadFile(in); if(End->name[0]=='\0')break; End->Next=newStaff; End=End->Next; } in.close(); cout<<"\t\t读取职工工资信息成功! "< } } //*********析构函数**********4 Staffmassage: : ~Staffmassage() { Save(); for(Staff*temp;Head->Next! =End;) { temp=Head->Next; Head->Next=Head->Next->Next; deletetemp; } deleteHead,End; } //*********菜单***********5 voidStaffmassage: : ShowMenu() { cout<<"*欢迎进入职工工资管理系统*"< cout<<"*******************************************************************************"< cout<<"*1.增加工资信息*"< cout<<"*2.显示工资信息*"< cout<<"*3.查找工资信息*"< cout<<"*4.删除工资信息*"< cout<<"*5.修改工资信息*"< cout<<"*0.安全退出系统*"< cout<<"\n\t\t\n\t\t请选择: "; } //************查找函数**********6 voidStaffmassage: : Find() { charname[20],number[10]; intx; Staff*p=NULL; cout<<"\n\t\t*********************************\n"; cout<<"\t\t*1.按职工的姓名查找\n\t\t*2.按职工的卡号查找"; cout<<"\n\t\t*请选择: "; cin>>x; switch(x) { case1: {cout<<"\t\t请输入要查找的职工的姓名: ";cin>>name; if(p=FindItem(name)) { p->Next->Show(); cout<<"请继续……"; getch(); } else { cout<<"\t\t没有找到! "<<'\n'< cout<<"请继续……"; getch(); } }break; case2: { cout<<"\t\t请输入要查找的职工的卡号: ";cin>>number; if(p=Findnumber(number)) { p->Next->Show(); cout<<"请继续……"; getch(); } else { cout<<"\t\t没有找到! "<<'\n'< cout<<"请继续……"; getch(); } }break; } } //***********修改信息***********7 voidStaffmassage: : ModifyItem()//修改信息 { charname[10]; Staff*p=NULL; cout<<"\t\t请输入要修改职工的姓名: ";cin>>name; if(p=FindItem(name)) { cout<<"\t\t已找到职工的信息,请输入新的信息! "< p->Next->Input(); cout<<"修改成功! "< cout<<"请继续……"; getch(); } else { cout<<"\t\t没有找到! "< cout<<"请继续……"; getch(); } } //***********删除信息**********8 voidStaffmassage: : RemoveItem()//删除信息 { charname[10]; Staff*p=NULL,*temp=NULL; cout<<"\t\t请输入要删除的职工的姓名: "< if(p=FindItem(name)) { temp=p->Next; p->Next=p->Next->Next; deletetemp; cout<<"\t\t删除成功! "< cout<<"请继续……"; getch(); } else { cout<<"\t\t没有找到! "< cout<<"请继续……"; getch(); } } //************保存函数***********OK10 voidStaffmassage: : Save() { out.open("sort.txt"); for(Staff*p=Head->Next;p! =End;p=p->Next) out< < out.close(); } //************工资统计*********** voidStaffmassage: : Tongji() { intcardNum; intin[2]; inttotal=0; cout<<"\t\t请输入要统计职工的卡号: "< cout<<"\t\t请输入要统计的开始日期: "< cout<<"\t\t请输入要统计的结束日期: "< Staff*tmp=NULL; tmp=Head; while(tmp){ if(tmp->number==cardNum){ if(tmp->month>=in[0]&&tmp->month<=in[1]) total+=tmp->Final_Salary; } tmp=tmp->next; } printf("职工%s的总工资是%d\n",cardNum,total); } //*********排序********** voidmySort(){ inttype[1]; cout<<"*请选择排序方式*"< cout<<"*******************************************************************************"< cout<<"*1.工资卡号升序*"< cout<<"*2.实发工资降序*"< cout<<"*3.姓名字典序排序*"< cin>>type[0]; switch(type[0]){ case: 1 { Staff*q,*tail,*p=(Staff*)malloc(sizeof(Staff)),*temp; p->next=head; head=p; tail=NULL; while(tail! =head->next) { p=head; q=p->next; while(q->next! =tail) { if(p->next->number>q->next->number) { temp=q->next->next; p->next=q->next; p->next->next=q; q->next=temp; } p=p->next; q=p->next; } tail=q; } p=head->next; free(head); }; break; case: 2 { Staff*q,*tail,*p=(Staff*)malloc(sizeof(Staff)),*temp; p->next=head; head=p; tail=NULL; while(tail! =head->next) { p=head; q=p->next; while(q->next! =tail) { if(p->next->Final_Salary { temp=q->next->next; p->next=q->next; p->next->next=q; q->next=temp; } p=p->next; q=p->next; } tail=q; } p=head->next; free(head); }; break; case: 3 { Staff*q,*tail,*p=(Staff*)malloc(sizeof(Staff)),*temp; p->next=head; head=p; tail=NULL; while(tail! =head->next) { p=head; q=p->next; while(q->next! =tail) { if(strcmp(p->next->name,q->next->name)>0) { temp=q->next->next; p->next=q->next; p->next->next=q; q->next=temp; } p=p->next; q=p->next; } tail=q; } p=head->next; free(head); }; ;break; default: break; } Display(); } //************主函数***********11 intmain() { system("color012");
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 调式 错误
![提示](https://static.bdocx.com/images/bang_tan.gif)