虚基类-在职读书的教师类

Problem Description

定义并描述一个人员类Person,它派生出学生类Student和教师类Teacher,学生类和教师类又共同派生出在职读书的教师类StuTech。人员类有姓名、性别、身份证号、出生年月等信息;学生类除继承来的以外有学号、成绩等信息;教师类有职称等信息。要求:将相应的类定义完整,并在main函数中定义StuTech的对象,输出对象的所有信息。

 Input

输入包括多组测试数据,每组数据包括:姓名,性别,身份证,出生年,月,学号,成绩,职称

 Output

每组测试数据输出多行

 Sample Input

Tom Man 350100198505020035 1985 5 2011010230 85 Lecturer

 Sample Output

The imformation of study-teacher is:
Name:Tom Sex:Man Identity card:350100198505020035 Birthday:1985.5
Num:2011010230 Score:85
profession:Lecturer

 Author

wj

 Source

14信管期末复习上机练习A

 Recommend

zh

**************************************************************************************************************************************************************

#include

using namespace std;
class Person{
private:
char*pname;
char*sex;
char *id;
int year;
int month;
public:
Person( char*name,char*sex1,char *id1,int year,int month)
{
pname=new char[strlen(name)+1];
strcpy(pname,name);
sex=new char[strlen(sex1)+1];
strcpy(sex,sex1);
id=new char[strlen(id1)+1];
strcpy(id,id1);
this->year=year;
this->month=month;
}
void show()
{
cout<<"Name:"< }


~Person()
{}
};
class Student:public Person{
private:
char *num;
int score;
public:
Student(char*name,char*sex1,char *id1,int year,int month,char*n,int score):Person(name,sex1,id1,year,month)
{
num=new char[strlen(n)+1];
strcpy(num,n);
this->score=score;
}
void show()
{


Person::show();
cout<<"Num:"< }
~Student()
{}
};
class Teacher:public Person{
private:
char *pro;
public:
Teacher(char*name,char*sex1,char *id1,int year,int month,char*p):Person(name,sex1,id1,year,month)
{
pro=new char[strlen(p)+1];
strcpy(pro,p);
}
void show1()
{
cout<<"profession:"< }
};
class StuTech:public Student,public Teacher{
public:
StuTech(char*name,char*sex1,char *id1,int year,int month,char*n,int score,char*p):Student(name,sex1,id1,year,month,n,score),Teacher(name,sex1,id1,year,month,p)
{
}
void show()
{
cout<<"The imformation of study-teacher is:"< Student::show();
Teacher::show1();
}
};
int main()
{
char a[25];
char b[25];
char c[25];
int d,f;
char g[100];
int h;
char t[100];
while(cin>>a>>b>>c>>d>>f>>g>>h>>t)
{
StuTech f(a,b,c,d,f,g,h,t);
f.show();
}
return 0;

}





完整不是水的!!!!

你可能感兴趣的:(虚基类-在职读书的教师类)