(继承类)帮忙找原因 能说的详细点
//定义一个基类person类,数据成员包含age,name,从该类派生一个employee(雇主)类,新增数据成员number(职工号);//再从employee类派生一个executive(执行官)类,新增数据成员level(头衔),每个类中都定义相应的函数为其赋值,
//并定义函数显示相关的信息,如( "Smith is 28 years old,is an employee")或( "Smith is 30 years old,is an executive,level is the 2"),
//编写一个main函数,生成两个数组,一个包含三个executive对象,一个包含三个employee对象,然后显示他们的相关信息;
#include<iostream.h>
#include<string.h>
#define maxsize 20
class person
{
private:
int age;
char name[maxsize];
public:
person(int a,char n[maxsize])
{
cout<<"执行构造函数person"<<endl;
age=a;
strcpy(name,n);
}
void Aprint();
};
void person::Aprint()
{
cout<<name;
cout<<" is "<<age<<" years old,";
}
class employee:public person
{
private:
char number[maxsize];
public:
employee(char N[maxsize],int a,char n[maxsize]):person(a,n)
{
cout<<"执行构造函数employee"<<endl;
strcpy(number,N);
}
void Bprint()
{
Aprint();
cout<<number<<" is a employee. ";
}
};
class executive:public employee
{
private:
char level[maxsize];
public:
person Q;
executive(char L[maxsize],int a,char n[maxsize],char N[maxsize]):Q(a,n),employee(N)
{
cout<<"执行构造函数executive:"<<endl;
strcpy(level,L);
}
void Cprint();
};
void executive::Cprint()
{
Bprint();
cout<<" level is a "<<level<<"."<<endl;
}
void main()
{
employee x("#001",19,"顾超");
x.Bprint();
executive y("科长",29,"顾超","@007");
y.Cprint();
}