#includeiostream#includefstream#includeconio.h#includeiomanip#includestringusingnamespacestd;//***********************************************************************************************************************//*****************************定义一个人类***************************************************************************classPerson{protected:intage;stringname;stringsex;public:Person(){name=小强;age=19;sex=男;}Person(stringn){name=n;}Person(stringn,inta,strings){name=n;age=a;sex=s;}voidsetname(){cinname;}voidsetsex();voidsetage();boolisname(strings){if(name==s)returntrue;elsereturnfalse;}boolissex(strings){if(sex==s)returntrue;elsereturnfalse;}boolisage(ints){if(age==s)returntrue;elsereturnfalse;}boolbiage(inta,intb){if(age=a&&age=b)returntrue;elsereturnfalse;}stringoutname(){returnname;}stringoutsex(){returnsex;}intoutage(){returnage;}virtualvoidshowStatus()=0;virtualvoidplay()=0;voidshowPerson();};voidPerson::setsex(){boolbo=true;while(bo){stringt[]={男,女,man,woman};cinsex;for(inti=0;i4;i++){if(sex==t[i]){bo=false;break;}}if(bo)cout请输入(男或女;manorwoman)endl;}}voidPerson::setage(){while(true){boolboo=true;chara[4];cina;for(inti=0;a[i];i++){if(!(((int)a[i])47&&((int)a[i])58)){cout年龄是纯数字的!\n请重新输入:;boo=false;break;}}if(boo){age=atoi(a);if(age151||age=0)cout请输入一个大于0小于150的数endl;elsebreak;}}}voidPerson::showPerson(){cout姓名:nameendl;cout年龄:ageendl;cout性别:sexendl;}//***********************************************************************************************************************//****************************定义一个教师类,从人公有继承***************************************************************classTeacher:virtualpublicPerson{protected:stringtitle;public:Teacher():Person(){title=教师;}Teacher(stringn,inta,strings,stringt):Person(n,a,s),title(t){}voidsettitle(){cintitle;}boolistitle(strings){if(title==s)returntrue;elsereturnfalse;}stringouttitle(){returntitle;}voidshowStatus();voidplay();};voidTeacher::showStatus(){showPerson();cout职称:titleendl;}voidTeacher::play(){coutsetw(10)namesetw(10)agesetw(10)sexsetw(10)titleendl;}//**********************************************************************************************************************//**********************************定义一个体育成绩类******************************************************************classTime{public:Time(){hour=0;minute=0;second=0;}Time(ints){second=s;}Time(intm,ints){minute=m;second=s;}Time(inth,intm,ints){hour=h;minute=m;second=s;}Timeoperator+(Time&);intTtoS();voidcinTime(int&);voidsetTime();voiddisplay();protected:inthour;intminute;intsecond;};intTime::TtoS(){intc=second+minute*60+hour*3600;returnc;}TimeTime::operator+(Time&t){Timec;c.second=c.second+t.second;c.minute=minute+t.minute;c.hour=hour+t.hour;if(c.second=60){c.minute++;c.second-=60;if(c.minute=60){c.hour++;c.minute-=60;}}returnc;}voidTime::display(){coutsetiosflags(ios::right)setfill('0')setw(2)hour:setfill('0')setw(2)minute:setfill('0')setw(2)secondsetfill('')resetiosflags(ios::right);}voidTime::cinTime(int&time){while(true){boolboo=true;chara[3];cina;for(inti=0;a[i];i++){if(!(((int)a[i])47&&((int)a[i])58)){cout时间是纯数字的!\n请重新输入:;boo=false;break;}}if(boo){time=atoi(a);if(time151||time0)cout请输入一个小于60的数endl;elsebreak;}}}voidTime::setTime(){cout\n用时多少时:;cinTime(hour);cout\n用时多少分:;cinTime(minute);cout\n用时多少秒:;cinTime(second);if(second=60){++minute;second-=60;}if(minute=60){++hour;minute-=60;}}//*********************************************************************************************************************//****************************定义一个学生的基类,从人公有继承**************************************************************classStu:virtualpublicPerson{protected:intnum;floatsco;stringzy;public:Stu():Person(){num=10001;sco=99;zy=计算机;}Stu(stringn):Person(n){}Stu(stringn,inta,strings,stringz):Person(n,a,s),zy(z){}Stu(stringn,inta,strings,intnu,stringz,floatsc):Person(n,a,s),num(nu),zy(z),sco(sc){}boolisnum(ints){if(num==s)returntrue;elsereturnfalse;}boolissco(floats){if(sco==s)returntrue;elsereturnfalse;}booliszy(strings){if(zy==s)returntrue;elsereturnfalse;}boolbinum(inta,intb){if(num=a&&num=b)returntrue;elsereturnfalse;}boolbisco(inta,intb){if(sco=a&&sco=b)returntrue;elsereturnfalse;}intoutnum(){returnnum;}floatoutsco(){returnsco;}stringoutzy(){returnzy;}voidplayname(){coutsetw(10)name;}voidsetnum();voidsetsco();voidsetzy(){cinzy;}voidshowStatus();voidshowStu0();voidplay(){}};voidStu::setnum(){boolbo=true;while(bo){boolboo=true;chara[4];cina;for(inti=0;a[i];i++){if(!(((int)a[i])47&&((int)a[i])58)){cout学号是纯数字的!\n请重新输入:;boo=false;break;}}if(boo){num=atoi(a);bo=false;}}}voidStu::setsco(){while(true){chara[3];cina;if(!(((int)a[0])47&&((int)a[0])58||((int)a[1])47&&((int)a[1])58||((int)a[2])47&&((int)a[2])58)){}elsesco=atoi(a);if(sco101||sco=0)cout请输入一个小于100的数endl;elsebreak;}}voidStu::showStatus(){cout学号:numendl;showPerson();cout成绩:scoendl;cout专业: