主题:错误在哪里啊??
#include<iostream>
#include<string>
using namespace std;
class Person
{ public:
Person(char*number,char*thename);
char*getnumber();
char*getname();
protected:
char*Nu;
char*name;
};
Person::Person(char*number,char*thename)
{Nu=number;
name=thename;
}
char *Person::getnumber()
{return Nu;
}
char *Person::getname()
{return name;
}
class Student:public Person
{public:
Student();
Student(char*number,char*thename,char*researchs):Person(number,thename)
{research=researchs;}
char*getresearchs()
{return research;}
protected:
char*research;
};
class Teacher:public Person
{ public:
int ii;
Teacher(char*number,char*thename,int i=0):Person(number,thename){}
void set()
{ii=0;}
void add_a_student(Student&stu)
{s[ii]=stu;
ii++;
}
void display();
protected:
char*mings;
Student s[20];
};
void Teacher::display()
{ cout<<"研究生导师:"<<"\n"<<"\t"<<Nu<<","<<name<<endl;
cout<<"研究生:"<<endl;
for(int i=0;i<ii;i++)
{
s[i].getnumber();
s[i].getname();
s[i].getresearchs();
}
};
void main()
{Teacher a("t1","黄东军");
Teacher b("t2","张云峰");
Student s1("99101","陈磊","人工智能");
Student s2("99102","崔大红","数据仓库");
Student s3("99103","王涛涛","数据结构");
Student s4("99104","宋丹","计算机网络");
a.add_a_student(s1);
a.add_a_student(s2);
a.add_a_student(s3);
b.add_a_student(s4);
a.display();
b.display();
}
请哪位高手帮忙改一下咯。。
#include<string>
using namespace std;
class Person
{ public:
Person(char*number,char*thename);
char*getnumber();
char*getname();
protected:
char*Nu;
char*name;
};
Person::Person(char*number,char*thename)
{Nu=number;
name=thename;
}
char *Person::getnumber()
{return Nu;
}
char *Person::getname()
{return name;
}
class Student:public Person
{public:
Student();
Student(char*number,char*thename,char*researchs):Person(number,thename)
{research=researchs;}
char*getresearchs()
{return research;}
protected:
char*research;
};
class Teacher:public Person
{ public:
int ii;
Teacher(char*number,char*thename,int i=0):Person(number,thename){}
void set()
{ii=0;}
void add_a_student(Student&stu)
{s[ii]=stu;
ii++;
}
void display();
protected:
char*mings;
Student s[20];
};
void Teacher::display()
{ cout<<"研究生导师:"<<"\n"<<"\t"<<Nu<<","<<name<<endl;
cout<<"研究生:"<<endl;
for(int i=0;i<ii;i++)
{
s[i].getnumber();
s[i].getname();
s[i].getresearchs();
}
};
void main()
{Teacher a("t1","黄东军");
Teacher b("t2","张云峰");
Student s1("99101","陈磊","人工智能");
Student s2("99102","崔大红","数据仓库");
Student s3("99103","王涛涛","数据结构");
Student s4("99104","宋丹","计算机网络");
a.add_a_student(s1);
a.add_a_student(s2);
a.add_a_student(s3);
b.add_a_student(s4);
a.display();
b.display();
}
请哪位高手帮忙改一下咯。。