




已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
实验4 继承与派生班级 网络1311 学号 39 姓名 付豪 成绩 一、实验目的1. 熟练掌握类的继承,能够定义和使用类的继承关系2. 掌握派生类的声明与实现方法3. 掌握类构造函数的初始化列表与作用域分辨率的使用方法4. 理解虚基类在解决二义性问题中的作用.二、实验内容1定义一个基类有姓名、性别、年龄,再由基类派生出教师类和学生类,教师类增加工号、职称和工资,学生类增加学号、班级、专业和入学成绩,在main()函数中定义基类和派生类对象,对类进行测试。2声明一个哺乳动物Mammal类,再由此派生出狗Dog类,声明一个Dog类的对象,观察基类与派生类的构造函数与析构函数的调用顺序。3定义一个Point类,派生出矩形类Rectangle和圆类Circle,计算各派生类对象的面积Area()。4设计一个圆类circle和一个桌子类table,另设计一个圆桌类roundtable,它是从前两个类派生的,要求输出一个圆桌的高度、面积和颜色等数据。 5定义一个大学生类student,函数私有数据成员:姓名、学号、校名,并为它定义带参数的构造函数,参数带缺省值的构造函数和输出数据成员值的print()公有成员函数,另定义研究生类,它以公有继承方式派生于类student,新增加“研究方向、导师名”两个私有数据成员,并定义带参数的构造函数和输出研究生数据的print()公有成员函数。在main()函数中定义基类和派生类对象,对类进行测试。三、实验源程序、测试与结论1#include#includeusing namespace std;class personstring name; char sex;int age;public:person(string n,char s,int a):name(n),sex(s),age(a) void show()coutnameendl; coutsexendl;coutageendl;class teacher:public personint num; string job; int money;public:teacher(string n,char s,int a,int nu,string j,int m):person(n,s,a),num(nu),job(j),money(m) void show()person:show();coutnumendl;coutjobendl;coutmoneyendl;class student:public personint num; string Class; string zhuanye; float sorce;public:student(string n,char s,int a,int nu,string C,string z,float ss):person(n,s,a),num(nu),Class(C),zhuanye(z),sorce(ss) void show()person:show(); coutnumendl;coutClassendl;coutzhuanyeendl;coutsorceendl;void main() teacher t1(Fsda,M,1234,74,jiaoshi,8000); student s1(Hfgh,F,1145,1001,BX1311,wangluo,511); t1.show();coutendlendl;s1.show();2#includeusing namespace std;class Mammalpublic:Mammal()coutMammal构造endl;Mammal()coutMammal析构endl;class Dog:public Mammalpublic:Dog()coutDog构造endl;Dog()coutDog析构endl;void main() Dog a;3.#includeusing namespace std;class Pointdouble x;double y;public:Point(double x,double y):x(x),y(y)void show()cout(x,y)endl;class Rectangle:public Point double x, y;public:Rectangle(double x,double y,double x1,double y1):Point(x,y),x(x1),y(y1)void Area()Point:show();cout:x*yendl;class Circle:public Pointdouble r;public:Circle(double x,double y,double c):Point(x,y),r(c)void Area()Point:show();cout:r*r*3.14endl;void main() Rectangle f2(5,6,7,8); Circle f3(1,2,3);f2.Area();f3.Area();4.#include#includeusing namespace std;class Circleint r;public:Circle(int r1)r=r1;class Tableint h;string color;public:Table(int h1,string c1)h=h1;color=c1;class Roundtable:public Circle,public Tablepublic:Roundtable(int x,int y,string z):Circle(x),Table(y,z) cout高度:x面积:y颜色:zendl;void main() string c; cout请输入颜色:c;Roundtable a(7,11,c);5.#include#includeusing namespace std;class student protected: string name; int num; string school;public:student(string n=hi,int a=0,string b=bey):name(n),num(a),school(b)void print() coutname:nameendl; coutnum: numendl; coutschool:schoolendl;class graduate:public student string research_area;string tutor_name;public:graduate(string a,int b,string c,string d,string e): student(a,b,c),research_area(d),tutor_name(e)void print() coutname:nameendl; coutnum: numendl; coutschool:schoolendl;/*/student:print();coutresearch_area:research_areaendl;couttutor_name:tutor_nameendl;void main() graduate g(Fsda,17,DJ,wangluo,Tao); coutgraduate:endl;g.print(); coutendlendl;student s(Fuh,11,DJ);coutstudent:endl;s.print();四、实验小结能够较好地应用类的继承,能够定义和使用类的继承关系掌握了派生类的声明与实现方法对类构造函数的初始化列表与作用域的使用更加熟悉理解虚基类在解决二义性问题中的作用.为搞好山东省交通科学研究所研发基地项目的结算审计工作,我跟踪审计部特针对本项目作如下要求,请各施工单位、供货单位遵照执行:and performance test copies of the record. If necessary, review should be carried out; 4) for spring hangers (included simple spring, hangers and constant support hangers) it should also be recognized as setting and locking of loads. 5) check the surface quality, folded layering and without cracks, rust and other defects. 5) after completion of the test and control drawing number one by one, by series baled. Color alloy steel parts, the parts marking installation location and rotation about the direction you want. 7.3.14. hangers installation 7.3.14.1 hanger layout a. a clear design of hanger should be installed strictly in accordance with the drawings and designs shall not be installed wrong, missing, etc. B. own arrangement of piping support and hanger set and selection should be based on comprehensive analysis of general layout of piping systems; cold installation of steam pipe with particular attention reserved for compensation of thermal expansion displacement and orientation. C. support systems should be rational to withstand pipe loads, static load and incidental load; reasonable piping displacement; guaranteed under various conditions, stress are within the allowed range. Strength, stiffness, and meet requirements to prevent vibration and soothing water, without affecting the adjacent equipment maintenance and other piping installation and expansion. D. equipment connected to the interface to meet pipeline thrust (torque) limit requirements; increase the stability of piping systems to prevent pipeline . Tube wall thickness (mm) 2-3 4-6 7-10 weld form no slope mouth weld strengthening height h (mm) 1-1.5 1.5-2 weld width b (mm) 5-6 7-6 has slope mouth weld streng
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- GB/T 4706.128-2025家用和类似用途电器的安全第128部分:新风净化机的特殊要求
- GB/T 21674-2025猪圆环病毒病诊断技术
- GB/T 46201-2025纤维增强复合材料单向增强材料Ⅰ型-Ⅱ型混合层间断裂韧性的测定
- 化工全员安全培训方案课件
- 初级辐射安全培训体会课件
- 承包方不承担全部安全责任的合同5篇
- 初升高衔接班介绍课件
- 拼多多白酒营销方案(3篇)
- 台球城活动营销方案(3篇)
- 初中教职工安全培训档案课件
- 10月高一月考地理试卷
- 配料间安全管理制度
- 2025年国家能源集团神东煤炭招聘笔试冲刺题(带答案解析)
- JG 3035-1996建筑幕墙
- 大宗商品贸易管理制度
- 2025年广西贵港桂平市交通旅游投资发展有限公司招聘笔试参考题库含答案解析
- 融资费用居间合同协议
- 舞蹈教育学理论课
- 帮人贷款协议书范本
- 七年级上册人教版历史知识点总结
- 《外购仔猪的管理》课件
评论
0/150
提交评论