幼小衔接数学题目:C++高手进啊,十万火急,在线等!!
来源:百度文库 编辑:神马品牌网 时间:2024/08/31 11:41:13
只需要给我编出:由cStudent类派生出研究生类cGraduate的就行了!~
#include<iostream.h>
#include<string.h>
class cPeople
{
protected:
char name[10];
char sex[5];
int old;
public:
cPeople(char n[],char s[],int o)
{
strcpy(name,n);
strcpy(sex,s);
old=o;
}
~cPeople(void){}
void print(void)
{
cout<<"姓名:"<<name<<endl;
cout<<"性别:"<<sex<<endl;
cout<<"年龄:"<<old<<endl;
}
};
class cStudent:virtual public cPeople
{
protected:
int no;
int year;
int month;
int day;
int mark;
public:
cStudent(char n[],char s[],int o,int nov,int y,int m,int d,int mk):
cPeople(n,s,o)
{
no=nov;
year=y;
month=m;
day=d;
mark=mk;
}
~cStudent(void){}
void print(void)
{
cPeople::print();
cout<<"学号:"<<no<<endl;
cout<<"入学时间:"<<year<<"年"<<month<<"月"<<day<<"日"<<endl;
cout<<"入学分数:"<<mark<<"分"<<endl;
}
};
class cGraduate:public cStudent
{
protected:
char direct[20];
char leadtech[10];
public:
cGraduate(char n[],char s[],int o,int nov,int y,int m,int d,int mk,char dr[],char ldt[]):
cStudent(n,s,o,nov,y,m,d,mk),cPeople(n,s,o)
{
strcpy(direct,dr);
strcpy(leadtech,ldt);
}
~cGraduate(void){}
void print(void)
{
cStudent::print();
cout<<"研究方向:"<<direct<<endl;
cout<<"研究导师:"<<leadtech<<endl;
}
};
class cTeacher:virtual public cPeople
{
protected:
char career[20];
char workgate[20];
int time;
public:
cTeacher(char n[],char s[],int o,char c[],char wg[],int t):
cPeople(n,s,o)
{
strcpy(career,c);
strcpy(workgate,wg);
time=t;
}
~cTeacher(void){}
void print(void)
{
cPeople::print();
cout<<"职务:"<<career<<endl;
cout<<"工作部门:"<<workgate<<endl;
cout<<"工作时间:"<<time<<"年"<<endl;
}
void printV(void)
{
cout<<"职务:"<<career<<endl;
cout<<"工作部门:"<<workgate<<endl;
cout<<"工作时间:"<<time<<"年"<<endl;
}
};
class cGradOnWork:public cGraduate,public cTeacher
{
public:
cGradOnWork(char n[],char s[],int o,int nov,int y,int m,int d,int mk,char dr[],char ldt[],char c[],char wg[],int t):
cGraduate(n,s,o,nov,y,m,d,mk,dr,ldt),
cTeacher(n,s,o,c,wg,t),
cPeople(n,s,o)
{}
void print(void)
{
cGraduate::print();
cTeacher::printV();
}
};
void main(void)
{
cStudent midstu("李明","男",13,24,2004,9,3,258);
cGraduate gua("张松丽","女",22,2,2003,6,15,490,"管理科学","张康");
cTeacher tech("张华","男",35,"老师","教研室",8);
cGradOnWork gandt("刘晓梅","女",23,1,2002,10,5,502,"信息管理","李强","教授","管理学院",2);
midstu.print();
gua.print();
tech.print();
gandt.print();
}
我学过好久了
只是现在没有代东西
不好说呀
你另请高人吧
昏……
上课要好好听讲啊
你问问同学啊!!!!!!1