




已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
郑州大学现代远程教育 面向对象程序设计课程考核要求说明:本课程考核形式为提交作业,完成后请保存为WORD 2003版本格式的文档,登陆学习平台提交,并检查和确认提交成功(能够下载,并且内容无误即为提交成功)。一 作业要求1.请独立自主完成作业内容。二 作业内容一)、简答题:(每题 5 分,共30 分)1什么是抽象类?它有什么特点?答: 抽象类与接口紧密相关,它们不能示例化,并且常常部分实现或根本不实现。 特点: 1、抽象类不能直接实例化 2、允许(但不要求)抽象类包含抽象成员。 3、抽象类不能被密封2 C+中使用多态的前提条件是什么? 答:动态多态的前提条件: 1.通过调用虚函数实现多态 2.通过基类的指针或引用调用虚函数3. 什么是类?类与结构有和不同? 答:类是引用类型在堆上分配,类的实例进行赋值只是复制了引用,都指向同一段实际对象分配的内存 不同:类有构造和析构函数,类可以继承和被继承结构没有构造函数,但可以添加。结构没有析构函数,结构不可以继承自另一个结构或被继承,但和类一样可以继承自接口。4. 面向对象的特征有哪些? 答:封装,继承,多态 5. 简述this指针的含义是什么? 答:this指针是一个隐含于每一个成员函数中的特殊指针。它是一个指向正在被该成员函数操作的对象,也就是要操作该成员函数的对象。6. 友元关系具有什么特点?答:友元函数的特点是能够访问类中的私有成员的非成员函数。友元函数从语法上看,它与普通函数一样,即在定义上和调用上与普通函数一样。二)、分析下面的代码,回答问题(每题 10 分,共 40 分)1 分析下面的代码,指出其中的错误,说明理由并改正class C public: int fn1( int x ) dm = x ; private: int dm; ;void main ( ) C c;c.fn1(16 );cout c.dm n;答:/dm为私有变量,是不能通过对象直接访问的,正确的做法是添加一个public类型的方法,如public void Show()coutdmendl;然后利用对象c调用Show(),2下面代码的执行结果是什么?为什么?class Aint n;public:A() ;A(int i)n=i;A() coutn=nendl;class B A a; int m;public:B(int i,int j):a(i)m=j;B()coutm=mendl;void main()B b(1,2);答:执行结果:n=1m=2原因:b对象里包含一个A类的对象,b对象在析构时先调用A的析构函数,再调用B自身的析构函数3.下面代码的执行结果是什么?为什么?class Sampleint n;public:Sample();Sample(int i)n=i;Sample& operator=(Sample);void disp()coutn=nendl;Sample & Sample:operator=(Sample s)Sample:n=s.n;return *this;void main()Sample s1(10),s2; s2=s1; s2.disp();答:结果:n=10Sample重载了赋值操作符,可以用Sample的一个对象去初使化另一个对象,s2对象被已经初使化的s1所初使化4. 下面代码的执行结果是什么?为什么?class Apublic:A(char *s) coutsendl;A();class B:virtual public Apublic:B(char *s1,char*s2):A(s1)couts2endl;class C:virtual public Apublic:C(char* s1,char* s2) : A(s1)couts2endl;class D: public B, public Cpublic:D(char *s1,char *s2,char *s3,char *s4):B(s1,s2),C(s1,s2),A(s1)couts4endl;创建对象的语句: D d(“class A”,”class B”,”class C”,”class D”);执行结果是什么?为什么?答:执行结果:class Aclass Bclass Cclass D三)、根据要求编写完整程序:(每题15分,共 30 分)1设计复数类的加法运算操作,使之能够执行下列运算:( 15 分)Complex x(3,6), y(4,5), z(0,0);z = x + y;z=2.4 + x;z=y + 3.5答:class complex public: complex(int r=0,int i=0);/构造 complex operator+(const complex& other); complex Complex:operator+(const int &a);void complex:input()protected: int real,image; ; void complex:input()int real,image;cout please enter a complex: rm;real = r;image = m;complex:complex(int r,int i) real=r; image=i; return; complex complex:operator+(const complex& other) complex temp; temp.real=real+other.real; temp.image=image+other.image; return temp; complex complex:operator+(const int &a)complex temp;temp.real= real +a;temp.image = image;return temp;int main(int argc,char* argv)complex a,b,c;a.input();b.input();c = a +b;/输出c = 5 +a;/输出c = b +5;/输出 2. 设计High类,其数据成员为高h,定义虚函数disp()。由High派生出长方体类Cuboid与圆柱体类Cylinder。在主函数中用基类指针变量p调用虚函数disp()显示长方体与圆柱体的体积。(15分)答:class Highpublic:unsigned int h;virtual void disp();class Cuboid:public HighPublic:unsigned int length;unsigned int width;virtual void disp()coutlength*width*hendl;Class Cylinder:public High Public:unsigned int r;/半径virtual void disp()cout3.14159*r*r*hdisp();objB.r=5;objB.h=10;p=&objB;p-disp();地形平坦开阔,地层由第四系全新冲积层,第四系上更新统冲层组成,局部表覆第四系全新统人工堆积层。第四系全新统冲积层厚度约2550m,岩性主要为黏土、粉质黏土、粉土、粉砂、细砂;第四系上更新统冲积层厚度大于50m,岩性主要为黏性土、粉土、粉细砂等。管桩深度范围内地层主要为:粉土、黏土、粉质黏土,局部表层为杂填土。coupling Centre shall be checked, the second poured concrete strength of more than 70%. In the process of reaming or boring, apart from the special provisions in factory, does not allow any work that may affect the coupling Centre, such as irrigation, to cylinder connections to flood the condenser pipes and so on. Well boring, hinge bolt hole flange with coupling of vertical, not oblique. Mounting bolts should be added lubricants, typing gently with a small hammer, not too loose or too tight, packed the bolts with the corresponding seal screw hole should be marked. 6.4.5.4.2 coupling reamed and pairings is close to the diameter of bolt bearing good hinge holes, dressed with a good two coupling bolts before you can move the rotor, boring-reaming hole in turn. Coupling bolts must be tight coupling is symmetrical diameter, in boring, reaming, two bolts out. Well boring, hinge bolt hole flange with coupling of vertical, not oblique. Due to the coupling bolts in accordance with hinge holes corresponding to the diameter of the screw holes one by one after processing, processing back bolt installation location cannot be changed, so according to bolt after the actual weight difference of nut and lock washer to match. General requirements for coupling two symmetrical diameter bolt, nut and lock washers total weight difference should not be greater than 10 g and knocks stamped mark. (See Figure 18) The coupling bolts apply lubricant, and then gently with copper home, not too loose or too tight. Bolt Assembly is finished, symmetrical tightening all bolts to 30%, 50%, 70%, 100% force, and check the coupling flutter and before connecting the circle gradually changes its value should be less
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年中考物理试题分类汇编(全国)电路、电流、电压、电阻(第1期)解析版
- 7.1 信息资源管理概述教学设计-2025-2026学年高中信息技术(信息科技)必修 信息技术基础教科版
- 6.拉拉手交朋友 一年级道德与法治上册(2024版)教学设计
- 6.4 微观世界与量子论教学设计-2025-2026学年高中物理上海科教版共同必修2-沪教版2007
- 2025年采油工(中级)考试试题题库
- 第7课 竖钩和弯钩说课稿-2025-2026学年小学书法练习指导三年级下册西泠版
- 蓄电池的维护和保养
- 2025年2月医师专业知识模考试题与答案
- 佛山期末考试小学试卷及答案
- 2025年水务部门考试题库及答案
- 驾照科目四模拟考试题及答案大全
- 电商用户社区与运营创新创业项目商业计划书
- 土地增值税清算培训课件
- 2025年青海省格尔木市辅警招聘考试试题题库及答案详解(易错题)
- 2025年中学生法治素养竞赛题库及答案
- 2025年部编版语文四年级上册全册单元、期中、期末测试题及答案(共10套)
- 村级妇联半年工作总结
- 数控安全培训课件
- 台球俱乐部工作管理制度
- 肉毒素中毒的治疗讲课件
- 蓝色简约风医学生职业生涯规划展示模板
评论
0/150
提交评论