error C2504: 'worker' : base class undefined 求大神修改一下!
classworker{private:charnum[8];charname[10];public:voidsetname(chars[]){strcpy(name,s...
class worker{
private:
char num[8];
char name[10];
public:
void setname(char s[]){strcpy(name,s);}
char *getname(){return name;}
void setnum(char n[]){strcpy(num,n);}
char *getnum(){return num;}
virtual void display();
/*派生类:workers*/
class workers:public worker{
private:
int age,sal;
char sex[6];
public:
void setage(int a){ age=a;}
void setsex (char s[]){strcpy(sex,s);}
void setsal (int s){sal=s;}
int getage (){ return age; }
char *getsex(){return sex;}
int getsal(){return sal;}
void display(){
cout<<"\t"<<getnum()<<"\t"<<getname()<<"\t";
cout<<getsex()<<"\t"<<getage()<<"\t"<<sal<<endl;
}
};
#endif 展开
private:
char num[8];
char name[10];
public:
void setname(char s[]){strcpy(name,s);}
char *getname(){return name;}
void setnum(char n[]){strcpy(num,n);}
char *getnum(){return num;}
virtual void display();
/*派生类:workers*/
class workers:public worker{
private:
int age,sal;
char sex[6];
public:
void setage(int a){ age=a;}
void setsex (char s[]){strcpy(sex,s);}
void setsal (int s){sal=s;}
int getage (){ return age; }
char *getsex(){return sex;}
int getsal(){return sal;}
void display(){
cout<<"\t"<<getnum()<<"\t"<<getname()<<"\t";
cout<<getsex()<<"\t"<<getage()<<"\t"<<sal<<endl;
}
};
#endif 展开
1个回答
展开全部
class worker{
private:
char num[8];
char name[10];
public:
void setname(char s[]){strcpy(name,s);}
char *getname(){return name;}
void setnum(char n[]){strcpy(num,n);}
char *getnum(){return num;}
virtual void display();
};
/*派生类:workers*/
class workers:public worker{
private:
int age,sal;
char sex[6];
public:
void setage(int a){ age=a;}
void setsex (char s[]){strcpy(sex,s);}
void setsal (int s){sal=s;}
int getage (){ return age; }
char *getsex(){return sex;}
int getsal(){return sal;}
void display(){
cout<<"\t"<<getnum()<<"\t"<<getname()<<"\t";
cout<<getsex()<<"\t"<<getage()<<"\t"<<sal<<endl;
}
#endif
private:
char num[8];
char name[10];
public:
void setname(char s[]){strcpy(name,s);}
char *getname(){return name;}
void setnum(char n[]){strcpy(num,n);}
char *getnum(){return num;}
virtual void display();
};
/*派生类:workers*/
class workers:public worker{
private:
int age,sal;
char sex[6];
public:
void setage(int a){ age=a;}
void setsex (char s[]){strcpy(sex,s);}
void setsal (int s){sal=s;}
int getage (){ return age; }
char *getsex(){return sex;}
int getsal(){return sal;}
void display(){
cout<<"\t"<<getnum()<<"\t"<<getname()<<"\t";
cout<<getsex()<<"\t"<<getage()<<"\t"<<sal<<endl;
}
#endif
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询