求助,这段带码报的这个错误
c++吧
全部回复
仅看楼主
level 1
5932800 楼主
#include<iostream.h>
#include<string.h>
#include<fstream.h>
class staff
{
     char number[20],type[20],name[20],education[20],branch[20],position[20];
     double age;
public:
     staff()
     {
     }
     staff(char n[20],char ty[20],char na[20],char edu[20],char bra[20],char pos[20],double a)
     {
         strcpy(number,n);
         strcpy(type,ty);
         strcpy(name,na);
         age=a;
         strcpy(education,edu);
         strcpy(branch,bra);
         strcpy(position,pos);
     }
         friend void main();
};
    
void main()
{
     cout<<"请选择您需要的操作!"<<endl;
     cout<<"(1)添加职工"<<endl;
     cout<<"(2)修改职工数据"<<endl;
     cout<<"(3)查询职工信息"<<endl;
     cout<<"(4)删除职工"<<endl;
     cout<<"(5)显示所有职工信息"<<endl;
  
     char p;char w;
     staff *s[50];
     ofstream *file[50];
     int i=0;
     int j=0;
     bool flag2=0;
     do
     {
         cin>>p;
         if((p>='1'&&p<='5'))
         flag2=1;
         else
     cout<<"指令错误!请重新输入:"<<endl;
     }while(flag2==0);
     do{
     switch(p)
     {
     case '1':
         {
             char d;
             char number[20],type[20],name[20],education[20],branch[20],position[20];
             double age;
             do{
                  cout<<"职工编号:";
                 cin>>number;

2010年01月03日 04点01分 1
level 1
5932800 楼主
                  cout<<"人员类型:";
                 cin>>type;
                 cout<<"姓名:";
                 cin>>name;
                 cout<<"年龄:";
                 cin>>age;
                 cout<<"学历:";
                 cin>>education;
                 cout<<"部门:";
                 cin>>branch;
                 cout<<"职务:";
                 cin>>position;
                 file[j]=new ofstream("d:\\document",ios::ate);
                 *file[j]<<"职工编号"<<number<<"人员类型"<<type<<"姓名"<<name<<"年龄"<<age<<"学历"<<education<<"部门"<<branch<<"职务"<<position;
                 j++;
                 s[i]=new staff(number,type,name,age,education,branch,position);
             i++;
                 cout<<"数据录入成功,想继续录入吗(y/n)"<<endl;
             cin>>d;
             flag2=0;
             do
             {
             if(d!='y'&&d!='n')
             {
                 cout<<"指令错误!请重新输入!"<<endl;

2010年01月03日 04点01分 2
level 1
5932800 楼主
                 cin>>d;
             }
             else
                 flag2=1;
             }while(flag2==0);
             }while(d=='y');
             break;
         }
     case '3':
         {
         char n[20];int j=0;char d;
             do{
             int flag=0;
             cout<<"请输入你要查询的职工编号"<<endl;
             cin>>n;
             for(int j=0;j<i;j++)
             {
                 if(strcmp(n,(*s[j]).number)==0)
                 {
                     flag=1;
                     cout<<"您要查询的职工是:"<<(*s[j]).number<<endl;
                    
                     cout<<"职工编号:"<<(*s[j]).number<<endl<<"人员类型:"<<(*s[j]).type<<endl<<"姓名:"<<(*s[j]).name<<endl<<"年龄:"<<(*s[j]).age<<endl<<"学历:"<<(*s[j]).education<<endl<<"部门:"<<(*s[j]).branch<<endl<<"职务:"<<(*s[j]).position<<endl;
                 }
             }
             if(flag==0)
             cout<<"对不起!您要查询的职工不存在!"<<endl;
             cout<<"您想继续查询吗?(y/n)"<<endl;

2010年01月03日 04点01分 3
level 1
5932800 楼主
             cin>>d;
             if(d!='y'&&d!='n')
             {
                 cout<<"指令错误!请重新输入!"<<endl;
                 cin>>d;
             }
             }
             while(d=='y');
             break;
         }
         case '4':
             {
                 char number[20];bool flag3=0;char d;
                 do{
                 cout<<"请输入您要删除的职工编号:"<<endl;
                 cin>>number;
                 for(int h=0;h<i;h++)
                 {
                     if(strcmp(number,s[h]->number)==0)
                     {
                         flag3=1;
                         i--;
                         do{
                             s[h]=s[h+1];
                             h++;
                         }while(h<=i);

2010年01月03日 04点01分 4
level 1
5932800 楼主
                     }
                 }
                 if(flag3==0)
                     cout<<"您要求删除的职工不存在!请重新输入!";
                 cout<<"要继续删除吗?(y/n)"<<endl;
                    cin>>d;
                  if(d!='y'&&d!='n')
             {
                 cout<<"指令错误!请重新输入!"<<endl;
                 cin>>d;
             }
             }while(d=='y');
             break;
         }
         case '2':
             {
                 char number[20],type[20],na[20],edu[20],bra[20],pos[20];double a;flag2=0;
                 char d;
             do
             {    
                 cout<<"请输入您要修改的职工的编号:"<<endl;
                 cin>>number;
                  for(int h=0;h<i;h++)
                 {
                 if(strcmp(number,s[h]->number)==0)
                 {
                     flag2=1;
                 cout<<"请输入新的人员类型:"<<endl;

2010年01月03日 04点01分 5
level 1
5932800 楼主
                 cin>>type;
                 cout<<"请输入新的姓名:"<<endl;
                 cin>>na;
                 cout<<"请输入新的年龄:"<<endl;
                 cin>>a;
                 cout<<"请输入新的学历:"<<endl;
                 cin>>edu;
                 cout<<"请输入新的部门:"<<endl;
                 cin>>bra;
                 cout<<"请输入新的职务:"<<endl;
                 cin>>pos;
                  
                    
                 cout<<"信息修改成功!";
                 }
                 }
                  if(flag2==0)
                  {
                      cout<<"您要修改的职工不存在!请检查重新输入!"<<endl;
                  }
             cout<<"想继续修改吗(y/n)"<<endl;
             cin>>d;
             if(d!='y'&&d!='n')
             {
                 cout<<"指令错误!请重新输入!"<<endl;
                 cin>>d;

2010年01月03日 04点01分 6
level 1
5932800 楼主
             }
             }while(d=='y');
             break;
         }
      case '5':
              {
                  cout<<"公司职工数据如下:"<<endl<<endl;
                  if(i==0)
                  cout<<"管理系统中没有录入数据或者数据已经被删除!"<<endl;
                  for(int k=0;k<i;k++)
                  {
                      cout<<"职工编号:"<<s[k]->number<<endl<<
                      "人员类型:"<<s[k]->type<<endl<<"姓名:"<<s[k]->name<<endl<<"年龄:"<<s[k]->age<<endl<<"学历:"<<s[k]->education<<endl<<"部门:"<<s[k]->branch<<endl<<"职务:"<<s[k]->position<<endl<<endl;
                  }
                  break;
              }
    
              break;
     }  
     cout<<"您想继续进行其他操作吗?(y/n)"<<endl;
         bool flag4=0;    
     do
         {
         cin>>w;
         if(w!='y'&&w!='n')
         cout<<"指令错误!请重新输入!"<<endl;
         else
             flag4=1;
         }while(flag4==0);
         if(w=='y')
             cout<<"请输入操作代码(1 添加员工/2 更新数据/3 查询职工信息/4 删除职工/5 显示所有职工信息)"<<endl;
         cin>>p;
     }while(w=='y');
     for(int x=0;x<i;x++)
     {
         delete s[x];
         cout<<"delete all members!"<<endl;
     }
          
}
中间                 s[i]=new staff(number,type,name,age,education,branch,position);
这句一直报我说age不能从double转为char
error C2664: '__thiscall staff::staff(char [],char [],char [],char [],char [],char [],double)' : cannot convert parameter 4 from 'double' to 'char []'

2010年01月03日 04点01分 7
level 14
你最后一个参数是double a
你调用的时候却把它放到了第四个
2010年01月03日 05点01分 8
level 14
s[i]=new staff(number,type,name/*,age*/,education,branch,position,age);
2010年01月03日 05点01分 9
1