| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 478 人关注过本帖
标题:帮忙看一下错哪了,谢谢!
只看楼主 加入收藏
rony
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-4-6
收藏
 问题点数:0 回复次数:2 
帮忙看一下错哪了,谢谢!
#include <iostream.h>
#include<string.h>
class worker
{public:
worker(int x,int y, char * z)
{number=x;age=y;strcpy(sex,z);};
~worker(){};
int Getnum(){return number;}
int Getage(){return age;}
char *Getsex(){return sex;}
void friend showlist(worker*&f);
void friend del1(worker*&f,int key);
void friend del2(worker*&f);
void friend f2(worker*&f);
void friend f1(worker*&f,worker*&r,int x,int y,char z);
worker*next;
private:
int number;
int age;
char* sex;
};
void f1(worker*&f,worker*&r,int x,int y,char* z)
{worker*p=new worker(x,y,z);
p->next=NULL;
if(f==NULL) {f=r=p;}
else{r->next=p;r=r->next;}
}
void showlist(worker*&f)
{worker*p1;
for(p1=f;p1!=NULL;p1=p1->next)
{cout<<p1->number<<" "<<p1->age<<" "<<p1->sex<<endl;}
}
void del1(worker*&f,int key)
{worker*p2;
worker*p3;
if(!f)
{cout<<"no worker!\n";return;}
if(f->number==key)
{p2=f;
f=f->next;
delete p2;
p2=NULL;
cout<<key<<"have been deleted\n";
return;
}
for(p3=f;p3!=NULL;p3=p3->next;)
{if(p3->next->number==key)
{p2=p3->next;
p3->next=p2->next;
delete p2;
p2=NULL;
cout<<key<<"have been deleted\n";
return;
}
cout<<"there is not key:"<<key<<endl;
return;
}
void del2(worker*&f)
{worker*p4;
worker *p5;
if(!f)
{cout<<"no worker!\n;
return;
}
if(f->sex=="man"&&f->age>=60||f->sex=="woman"&&f->age>=55)
{p4=f;
f=f->next;
f1(head,r1,p4->number,p4->age,p4->sex)
for(p5=f;p5->next!=NULL;p5=p5->next)
{if p5->next->sex=="man"&&p5->next->age>=60||p5->next->sex=="woman"&&p5->next->age>=55)
p4=p5->next;
p5->next=p4->next;
f1(head,r1,p4->number,p4->age,p4->sex);
delete p4;
p4=NULL;
return;
}
void f2(worker*&f)
{worker*p6;
int a,b;
for(p6==f;p6!=NULL;p6=p6->next;)
{if(p6->sex=="man")
a++;
if(p6->sex=="woman")
b++;
}
cout<<"共有男性职工人数为:"<<a<<endl;
cout<<"共有女性职工人数为:"<<b<<endl;
}
void main()
{worker*&front=NULL;*rear=NULL;worker*&head=NULL;worker*r1=NULL;
int x,y,choice,key;
char z;
do
{cout<<"please choice:\n";
cout<<"key in 1 is continue\n key in 0 is over\n";
cin>>choice;
switch(choice)
{case 1:{cout<<"Input number,age,sex:";
cin>>x>>y>>z;
f1(front,rear,x,y,z);
break;}
case 0:break;
}while(choice);
f2(front);
cout<<"
cout<<"请输入所要删除职工的编号:"<<key<<endl;
cin>>key;
del1(front,key);
f2(front);
del2(front);
f2(front);
showlist(head);
}
搜索更多相关主题的帖子: include public return number 
2007-04-06 05:13
zinking
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:35
帖 子:916
专家分:0
注 册:2004-12-5
收藏
得分:0 
你怎么也得给个编译器的错误信息啊

代码格式化不好

命名有问题

http://kongfuziandlife. http://codeanddesign.
2007-04-06 09:22
rony
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-4-6
收藏
得分:0 

yang1.cpp
F:\书籍\yang1.cpp(46) : error C2059: syntax error : ';'
F:\书籍\yang1.cpp(59) : error C2601: 'del2' : local function definitions are illegal
F:\书籍\yang1.cpp(59) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.

yang1.obj - 3 error(s), 0 warning(s)

2007-04-06 12:48
快速回复:帮忙看一下错哪了,谢谢!
数据加载中...
 
   



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

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