欢迎来到天天文库
浏览记录
ID:38698539
大小:73.00 KB
页数:6页
时间:2019-06-17
《实验四 继承与派生》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验四继承与派生班级:软件1002姓名:韩晓燕学号:201013138043指导老师:汪老师【实验内容】设计一个用于人员管理的“people(人员)”基类。考虑到通用性,仅只抽象出所有人员都具有的属性:编号、姓名、性别、出生日期、身份证号等;从people类派生出student类,并添加属性:班号classno;从people类派生出teacher类,并添加属性:职务principalship、部门department;从student类派生出graduate类,添加属性:专业subject、导师teacheradv
2、iser(teacher类);从graduate类和teacher类派生出TA类。设计时注意虚基类的使用,注意重载相应的函数。测试这个类。【实验目的】1.学习定义和使用类的继承关系,定义派生类;2.熟悉不同继承方式下对虚基类成员的访问控制;3.学习利用虚基类解决二义性问题。【UML图】6【程序清单】#includeusingnamespacestd;classdate{private:intyear;intmonth;intday;public:date(inty,intm,intd):year(
3、y),month(m),day(d){}voidshow();};voiddate::show(){cout<<"birthday:";cout<4、{};~People(){};voidshow();private:datebirth;intnum;char*name;intID;};voidPeople::show(){cout<<"num:"<5、tudent(People&p,student&s):People(p),classno(s.classno){}~student(){};voidshow1();private:intclassno;};voidstudent::show1(){show();cout<<"classno:"<6、{}teacher(People&p,teacher&t):People(p),PH(t.PH),DP(t.DP){}~teacher(){};voidshow2();voidshow2(int);private:char*PH;char*DP;};voidteacher::show2(){show();cout<<"principalship:"<7、:"<8、how3();private:char*sub;teachert;};voidgraduate::show3(){show1();cout<<"subject:"<
4、{};~People(){};voidshow();private:datebirth;intnum;char*name;intID;};voidPeople::show(){cout<<"num:"<5、tudent(People&p,student&s):People(p),classno(s.classno){}~student(){};voidshow1();private:intclassno;};voidstudent::show1(){show();cout<<"classno:"<6、{}teacher(People&p,teacher&t):People(p),PH(t.PH),DP(t.DP){}~teacher(){};voidshow2();voidshow2(int);private:char*PH;char*DP;};voidteacher::show2(){show();cout<<"principalship:"<7、:"<8、how3();private:char*sub;teachert;};voidgraduate::show3(){show1();cout<<"subject:"<
5、tudent(People&p,student&s):People(p),classno(s.classno){}~student(){};voidshow1();private:intclassno;};voidstudent::show1(){show();cout<<"classno:"<6、{}teacher(People&p,teacher&t):People(p),PH(t.PH),DP(t.DP){}~teacher(){};voidshow2();voidshow2(int);private:char*PH;char*DP;};voidteacher::show2(){show();cout<<"principalship:"<7、:"<8、how3();private:char*sub;teachert;};voidgraduate::show3(){show1();cout<<"subject:"<
6、{}teacher(People&p,teacher&t):People(p),PH(t.PH),DP(t.DP){}~teacher(){};voidshow2();voidshow2(int);private:char*PH;char*DP;};voidteacher::show2(){show();cout<<"principalship:"<7、:"<8、how3();private:char*sub;teachert;};voidgraduate::show3(){show1();cout<<"subject:"<
7、:"<8、how3();private:char*sub;teachert;};voidgraduate::show3(){show1();cout<<"subject:"<
8、how3();private:char*sub;teachert;};voidgraduate::show3(){show1();cout<<"subject:"<
此文档下载收益归作者所有