求大神帮忙看看,这程序得不到想要的结果,哪出问题了?
输入职工信息表,再根据这个表产生一个职工信息简表//CPP5.h
#if !defined(CPP5_H)
#define CPP5_H
#include<string>
#include<cstring>
#include<iostream>
using namespace std;
const int SIZE=10;
class worker
{
private:
char num[SIZE];
char name[SIZE];
public:
void setname(char []);
char *getname();
void setnum(char []);
char *getnum();
virtual void display();
};
class workers:public worker
{
private:
int age;
char sex[SIZE];
public:
void setage(int a);
void setsex(char s[]);
int getage();
char *getsex();
void display();
};
void printer(worker&);
#endif
//cpp5.cpp
#include"cpp5.h"
void worker::setname (char s[])
{strcpy(name,s);}
char* worker::getname ()
{return name;}
void worker::setnum(char n[] )
{strcpy(num,n);
}
char *worker::getnum ()
{return num;}
void worker::display ()
{
cout<<"\t"<<num<<"\t"<<name<<endl;
}
void workers::setage(int a)
{age=a;}
void workers::setsex (char s[])
{strcpy(sex,s);
}
int workers::getage()
{return age;}
char *workers::getsex ()
{return sex;}
void workers::display()
{
cout<<"\t"<<getnum()<<"\t"<<age<<"\t"<<getname()<<"\t"<<sex<<endl;
}
/*******************************
* 显示职工信息处理函数
*******************************/
void printer(worker&s)
{
s.display();
}
/*****************************
*主函数
*****************************/
void main()
{
workers wks[SIZE];
worker wk[SIZE];
int number(0);
char ch[10];
int age;
for(int j=0;j<SIZE;j++)
{
cout<<"\t编号:";
cin.getline(ch,'\n');
if(ch[0]=='0');
{
number=j;
break;
}
wks[j].setnum(ch);
cout<<"\t姓名:"<<endl;
cin.getline(ch,'\n');
wks[j].setname(ch);
cin.getline(ch,'\n');
wks[j].setsex(ch);
cin>>age;
cout<<"\t年龄:";
wks[j].setage(age);
getchar();
}
for(int i=0;i<number;i++)
wk[i]=wks[i];
cout<<"\n\t编号"<<"\t年龄"<<endl;
for(int i=0;i<number;i++)
printer(wks[i]);
cout<<"\n\t编号"<<"\t姓名"<<endl;
for(int i=0;i<number ;i++)
printer(wk[i]);
}
只出现编号,输入编号按Enter后直接结束,什么地方出错了?