欢迎来到天天文库
浏览记录
ID:55266701
大小:39.50 KB
页数:4页
时间:2020-05-08
《(C++)实验报告六:继承与派生.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实验6继承与派生一、实验目的1.理解继承与派生、单继承与多继承的概念;2.理解基类与派生类的定义及使用方法,派生类对象的定义与初始化方法;3.理解继承与派生过程中,把派生类作为基类构成类族的概念及虚基类的概念。二、实验环境一台PC机,WindowsXP操作系统,VisualC++6.0开发环境。三、实验内容1、由在校人员类(Person)作为基类派生出学生类(Student):实验步骤:#include#includeusingnamespacestd;classPerson{public:Person(
2、inti,char*n,chars,inta){ID=i;name=n;sex=s;age=a;};intgetID(){returnID;}voidshow(){cout<<"ID:"<3、,chars,inta,floatm,floatp,floate,floatc):Person(i,n,s,a){math=m;physical=p;english=e;cpp=c;total=math+physical+english+cpp;}voidshow(){Person::show();cout<<"math:"<4、total:"<#includeusingnamespacestd;classStuden5、t{public:Student(inti,char*n,chars,inta){No=i;Name=n;Sex=s;Age=a;};voidshow(){cout<<"No:"<6、o;Cname=name;Chour=hour;}voidshow(){cout<<"Cno:"<7、,Lesson(no,name,hour){Score=score;}voidshow(){Student::show();Lesson::show();cout<<"Score:"<8、am>#includeusingnamespacestd;classPoint{public:Point(intxx=0,intyy=0){x=xx;y=yy;}
3、,chars,inta,floatm,floatp,floate,floatc):Person(i,n,s,a){math=m;physical=p;english=e;cpp=c;total=math+physical+english+cpp;}voidshow(){Person::show();cout<<"math:"<4、total:"<#includeusingnamespacestd;classStuden5、t{public:Student(inti,char*n,chars,inta){No=i;Name=n;Sex=s;Age=a;};voidshow(){cout<<"No:"<6、o;Cname=name;Chour=hour;}voidshow(){cout<<"Cno:"<7、,Lesson(no,name,hour){Score=score;}voidshow(){Student::show();Lesson::show();cout<<"Score:"<8、am>#includeusingnamespacestd;classPoint{public:Point(intxx=0,intyy=0){x=xx;y=yy;}
4、total:"<#includeusingnamespacestd;classStuden
5、t{public:Student(inti,char*n,chars,inta){No=i;Name=n;Sex=s;Age=a;};voidshow(){cout<<"No:"<6、o;Cname=name;Chour=hour;}voidshow(){cout<<"Cno:"<7、,Lesson(no,name,hour){Score=score;}voidshow(){Student::show();Lesson::show();cout<<"Score:"<8、am>#includeusingnamespacestd;classPoint{public:Point(intxx=0,intyy=0){x=xx;y=yy;}
6、o;Cname=name;Chour=hour;}voidshow(){cout<<"Cno:"<7、,Lesson(no,name,hour){Score=score;}voidshow(){Student::show();Lesson::show();cout<<"Score:"<8、am>#includeusingnamespacestd;classPoint{public:Point(intxx=0,intyy=0){x=xx;y=yy;}
7、,Lesson(no,name,hour){Score=score;}voidshow(){Student::show();Lesson::show();cout<<"Score:"<8、am>#includeusingnamespacestd;classPoint{public:Point(intxx=0,intyy=0){x=xx;y=yy;}
8、am>#includeusingnamespacestd;classPoint{public:Point(intxx=0,intyy=0){x=xx;y=yy;}
此文档下载收益归作者所有