面向對象程序設計計科11c卷_第1頁
面向對象程序設計計科11c卷_第2頁
免費預覽已結束,剩余3頁可下載查看

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、象程序設計試題(C 卷 用題班級2使用const 定義常量與用使用define 中標,錯誤的標象程序設計試題(C 卷 用題班級2使用const 定義常量與用使用define 中標,錯誤的標C+只支持象程序設計派生類的成員函數(shù)可以直基類3操作符delete的作用是什么?如何刪除單個用new 申請的空間?如何刪除申請的delete 刪除一個類的對象時,會發(fā)生哪些操作?必要時,請用代碼說用class當一個對象被銷毀時,以與構造函數(shù)調用順序相反的順序調用析構函問答題(5 40 分一二三四五六8public、protected、private private 成員被繼承到子類后,其8public、pro

2、tected、private private 成員被繼承到子類后,其自動局部對象(Automaticlocalobjects)的構造函數(shù)、析構函數(shù)分別是什么時候被調用, 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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論