面向对象程序设计计科11c卷_第1页
面向对象程序设计计科11c卷_第2页
免费预览已结束,剩余3页可下载查看

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、象程序设计试题(C 卷 用题班级2使用const 定义常量与用使用define 中标,错误的标象程序设计试题(C 卷 用题班级2使用const 定义常量与用使用define 中标,错误的标C+只支持象程序设计派生类的成员函数可以直基类3操作符delete的作用是什么?如何删除单个用new 申请的空间?如何删除申请的delete 删除一个类的对象时,会发生哪些操作?必要时,请用代码说用class当一个对象被销毁时,以与构造函数调用顺序相反的顺序调用析构函问答题(5 40 分一二三四五六8public、protected、private private 成员被继承到子类后,其8public、pro

2、tected、private private 成员被继承到子类后,其自动局部对象(Automaticlocalobjects)的构造函数、析构函数分别是什么时候被调用, 1A classs data members (variables he class and functions (functions declared in the class definition) belong tot classs scope. Nonmember functions are defined at file scope.Within a classs scope, class members are y

3、 y all t member functions and can be referenced by name. Outside a classs scope, public class members are referenced through one of the handles on an objectan object name, reference toanobjectora er to an object.The type of the object, reference or specifieserface(i.e.,themember functions)sibleto th

4、e (注:在不影响理解前题下,下列程序均略去了必要的头文件、名称空间classBCsayHi()coutJusthi.调用BC类的sayHiendl; void run() cout in Base:run endl; classDC1:public 2In(注:在不影响理解前题下,下列程序均略去了必要的头文件、名称空间classBCsayHi()coutJusthi.调用BC类的sayHiendl; void run() cout in Base:run endl; classDC1:public 2In Section 13.3.1, we assigned the address of

5、a derived-class object to a base-voidrun()coutinker:runendl;er and t the C+ compiler allows this assignment, because classDC2:publicvoidsayHicout在Tailor中endlderived-class object is a base-class object. We take the ite approach in Fig. 13.6, abase-aEmployee member function, including setBaseSalary, f

6、or the to which the po the Commisos (i.e., the base-class object Employee). voidrun()coutailor:runendl;Employee object does not provide a setBaseSalary member function, does it provide a baseSalary data member to set. This could lead to problems, main()BC*member function setBaseSalary would t there

7、is a baseSalary data member its usual location in Employee object. This memory forwhich=1;which not belong to the Commis overwriteotherimportantdataEmployee, object so member function setBaseSalary which+) switch( which ) case 1: p = new BC; break; case2:p=newDC1;break; case 3:p= newDC2;deletesiblyhat belongstoadifferent returninreturnclassclassb; returnclassclassb; 1(8分)采用面、main() BInitualizingAA! InitualizingBB! Ending main!DestroyingBB! Destroying voidre

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论