求助急看了一下午也找不到错误
#include<iostream.h>#include<string.h>
class people
{
protected:
int age;
char name[20];
public:
people(char *n,int a):age(a)
{
strcpy(name,n);
}
void print()
{
cout<<"The name of the people is:"<<name<<endl<<"The age of the people is:"<<age<<endl<<endl;
}
};
class student:public virtual people
{
protected:
char classno[7];
public:
student(char *n,int a,char *c):people(n,a)
{
strcpy(classno,c);
}
void print()
{
cout<<"The name of the student is :"<<name<<endl<<"The age of the student is:"<<age<<endl;
cout<<"The classno of the student is :"<<classno<<endl<<endl;
}
};
class techer:public virtual people
{
protected:
char principalship[11];
char department[21];
public:
techer(char *n,int a,char *p,char *d):people(n,a)
{
strcpy(principalship,p);
strcpy(department,d);
}
void print()
{
cout<<"The name of the techer is :"<<name<<endl<<"The age of the techer is:"<<age<<endl;
cout<<"The principalship of the techer is:"<<principalship<<endl;
cout<<"The deparcipalship of the thcher is:"<<department<<endl<<endl;
}
};
class graduate:virtual public student
{
protected:
char subject[21];
techer adviser;
public:
graduate(char *n,int a,char *c,char *s,techer t):people(n,a),student(n,a,c),adviser(t)
{
strcpy(subject,s);
}
void print()
{
cout<<"The name of the graduate is:"<<name<<endl<<"The age of the gratuate is:"<<age<<endl;
cout<<"The calssno of the graduate is:"<<classno<<endl;
cout<<"The subject of the graduate is:"<<subject<<endl;
cout<<"The techer adviser of the graduate is:";
adviser.print();
}
};
class TA: public graduate, public techer
{
public:
TA(char *n,int a,char *s,techer t,char *p,char *d,char *c):people(n,a),student(n,a,c),techer(n,a,p,d),graduate(n,a,c,s,t){}
void print()
{
cout<<"The name of the TA is:"<<name<<endl<<"The age of TA is:"<<age<<endl;
cout<<"The calssno of the TA is:"<<classno<<endl;
cout<<"The subject of the TA is:"<<subject<<endl;
cout<<"The techer adviser of the TA is:";
adviser.print();
cout<<"The principalship of the techer is:"<<principalship<<endl;
cout<<"The deparcipalship of the thcher is:"<<department<<endl<<endl<<endl;
}
};
void main()
{
char n[20],int a;char classnumber[10];char department[21];
char principalship[11];char subject[10];
cout<<"输入姓名:"<<endl;
cin>>n;
cout<<"输入年龄:"<<endl;
cin>>a;
people f(n,a);
f.print();
cout<<"输入学生姓名:"<<endl;
cin>>n;
cout<<"输入学生年龄:"<<endl;
cin>>a;
cout<<"输入学生班级:"<<endl;
cin>>classnumber;
student b(n,a,classnumber);
b.print();
cout<<"输入姓名:"<<endl;
cin>>n;
cout<<"输入教师年龄:"<<endl;
cin>>a;
cout<<"输入教师职务:"<<endl;
cin>>principalship;
cout<<"输入教师部门"<<endl;
cin>>department;
techer c(n,a,principalship,department);
c.print();
cout<<"输入研究生姓名:"<<endl;
cin>>n;
cout<<"输入研究生年龄:"<<endl;
cin>>a;
cout<<"输入学生班级:"<<endl;
cin>>classnumber;
cout<<"研究生专业"<<endl;
cin>>subject;
graduate d(n,a,classnumber,subject,c);
d.print();
cout<<"输入助教姓名:"<<endl;
cin>>n;
cout<<"输入助教年龄:"<<endl;
cin>>a;
cout<<"输入助教班级:"<<endl;
cin>>classnumber;
cout<<"助教专业"<<endl;
cin>>subject;
TA e(n,a,subject,c,principalship,department,classnumber);
e.print();
}
[code][code][code][code][local]1[/local][/code][/code][/code][/code]