版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、專業(yè)好文檔計算機(jī)應(yīng)用專業(yè)“c+語言程序設(shè)計”課程作業(yè)第四次作業(yè)一、 填空題1. 在定義類對象的語句執(zhí)行時,系統(tǒng)在建立每個對象的過程中將自動調(diào)用該類的_構(gòu)造函數(shù)_使其初始化。2. 當(dāng)一個類對象被撤消時將自動調(diào)用該類的_析構(gòu)函數(shù)_。3. 對基類數(shù)據(jù)成員的初始化是通過執(zhí)行派生類構(gòu)造函數(shù)中的_初始化表_來實現(xiàn)的。4. 對一個類中的數(shù)據(jù)成員的初始化可以通過構(gòu)造函數(shù)中的_初始化表_實現(xiàn),也可以通過構(gòu)造函數(shù)中的_賦值語句_實現(xiàn)。5. 在一個派生類中,對基類成員、類對象成員和非類對象成員的初始化次序的先基類成員,后類對象成員,最后非對象成員。6. 當(dāng)撤消一個含有基類和類對象成員的派生類對象時,將首先完成派生類
2、本身的析構(gòu)函數(shù)定義體的執(zhí)行,接著完成類對象成員的析構(gòu)函數(shù)定義體的執(zhí)行,最后完成基類成員的析構(gòu)函數(shù)定義體的執(zhí)行。7. 設(shè)px是指向一個類動態(tài)對象的指針變量,則執(zhí)行“delete px;”語句時,將自動調(diào)用該類的析構(gòu)函數(shù)。8. 當(dāng)一個類對象離開它的作用域時,系統(tǒng)將自動調(diào)用該類的析構(gòu)函數(shù)。9. 假定一個類對象數(shù)組為an,當(dāng)離開它的作用域時,系統(tǒng)自動調(diào)用該類析構(gòu)函數(shù)的次數(shù)為n次。10. 假定ab為一個類,則執(zhí)行“ab a10;”語句時,系統(tǒng)自動調(diào)用該類構(gòu)造函數(shù)的次數(shù)為10次。11. 假定擁護(hù)沒有給一個名為ab的類定義構(gòu)造函數(shù),則系統(tǒng)為其隱含定義的構(gòu)造函數(shù)為空構(gòu)造函數(shù)。12. 假定用戶沒有給一個名為ab
3、的類定義析構(gòu)函數(shù),則系統(tǒng)為其隱含定義的析構(gòu)函數(shù)為空析構(gòu)函數(shù)。13. 若需要把一個函數(shù)“void f(); ”定義為一個類ab的友元函數(shù),則應(yīng)在類ab的定義中加入一條語句:friend void f();。14. 若需要把一個類ab定義為一個類cd的友元類,則應(yīng)在類cd的定義中加入一條語句:friend class ab;。15. 假定一個類ab中有一個靜態(tài)整型成員bb,在類外為它進(jìn)行定義并初始化為0時,所使用寫法為ab:bb = 0;。16. 假定類ab中有一個公用屬性的靜態(tài)數(shù)據(jù)成員bb,在類外不通過對象名訪問該成員 bb的寫法為ab:bb。17. 當(dāng)類中一個字符指針成員指向具有n個字節(jié)的儲存
4、空間時,它所能儲存字符串的最大長度為n-1。18. 假定ab為一個類,則該類的拷貝構(gòu)造函數(shù)的聲明語句為ab:ab(ab &)。19. 對類對象成員初始化是通過執(zhí)行構(gòu)造函數(shù)中的初始化表完成的。20. 對于類中定義的成員,其隱含訪問權(quán)限為private,對于結(jié)構(gòu)中定義的成員,其隱含訪問權(quán)限為public。21. 一個類的友元函數(shù)或友元類能夠通過成員操作符訪問該類的所有數(shù)據(jù)成員和函數(shù)成員。22. 假定要對類ab定義加號操作符重載成員函數(shù),實現(xiàn)兩個ab類對象的加法,并返回相加結(jié)果,則該成員函數(shù)的聲明語句為:ab operator +(ab, ab);。23. 在c+流類庫中,根基類為ios。24. 在
5、c+流類庫中,輸入流類和輸出流類的名稱分別為istream和ostream。25. 若要在程序文件中進(jìn)行標(biāo)準(zhǔn)輸入輸出操作,則必須在開始的#inlude命令中使用iosteam.h頭文件。26. 若要在程序文件中進(jìn)行文件輸入輸出操作,則必須在開始的#inlude命令中使用fstream.h頭文件。27. 當(dāng)從字符文件中讀取回車和換行兩個字符時,被系統(tǒng)看作為一個換行符。28. 當(dāng)使用ifstream流類定義一個流對象并打開一個磁盤文件時,文件的隱含打開方式為 讀取的文本文件,當(dāng)使用ofstream 流類定義一個流對象并打開一個磁盤文件時,文件的隱含打開方式為寫入的文本文件。29. 當(dāng)需要使用ist
6、rstream流類定義一個流對象并聯(lián)系一個字符串時,應(yīng)在文件開始使用#include命令,使之包含strstrea.h文件。二給出下列程序運行后的輸出結(jié)果1#includeclass aint a, b;public: a( ) a=b=0;a( int aa, int bb) a=aa; b=bb; couta bendl;void main( ) a x,y(6,3), z(8,10);6 38 102#includeclass aint a, b;public:a(int aa= 0, int bb= 0): a(aa),b(bb)coutconstructor! a + bendl;v
7、oid main()a x, y(2,5), z(y);constructor!0constructor!73#includeclass aint * a;public:a(int aa= 0)a = new int(aa);coutconstructor! * aendl;void main()a x2;a * p = new a(5);delete p;constructor!0constructor!0constructor!54#includeclass aint a;public:a(int aa= 0): a(aa)a()coutdestructor! a endl; void m
8、ain()a x(5);a * p = new a(10);delete p;destructor!10destructor!55#includeclass a int * a;public:a(int x)a = new int(x);coutconstructor! * aendl;a()delete a;coutdestructor!endl;void main()a x(9),* p;p = new a(12);delete p;constructor!9constructor!12destructor!destructor!6#includeclass aint a;public:a
9、(int aa= 0): a(aa)coutconstructor a! aendl;class b:public aint b;public:b(int aa, int bb): a(aa), b(bb)coutconstructor b! bendl;void main()b x(2,3),y(4,5);constructor a!2constructor b!3constructor a!4constructor b!57#includeclass aint a;public:a(int aa= 0)a = aa;a()coutdestructor a! aendl;class b:pu
10、blic aint b;public:b(int aa= 0, int bb= 0): a(aa)b = bb;b()coutdestructor b!bendl;void main()b x(5),y(6,7);deconstructor b!7deconstructor a!6deconstructor b!0deconstructor a!58#include#includeclass aint a,b;char op;public:a(int aa, int bb, char ch)a = aa;b = bb;op = ch;int comp()switch(op)case + :re
11、turn a + b;case - :return a - b;case * :return a * b;case / :if(b!=0)return a/b;else exit(1);case % :if(b!=0)return a%b;else exit(1);default:exit(1);void seta(int aa, int bb, char ch)a = aa;b = bb;op = ch;void main(void)a x(3,5,*);int a = x.comp();x. seta(4,9, +);a += x.comp();x. seta(13,8, %);a +=
12、x.comp();couta=aendl;a=339#includeclass bint a,b;public:b()a = b = 0;b(int aa, int bb)a = aa;b = bb;b operator +(b& x)b r;r . a = a + x . a;r . b = b + x . b;return r;b operator -(b& x)b r;r . a = a - x . a;r . b = b - x . b;return r;void outb()cout a b endl;void main()b x(6,5),y(13,3), z1, z2;z1 =
13、x + y;z2 = x - y;z1.outb();z2.outb();19 8-7 210#includetemplateclass fftt a1,a2,a3;public:ff(tt b1, tt b2, tt b3)a1 =b1;a2 =b2;a3 =b3;tt sum()return a1 + a2 + a3;void main()ff x(8,3,4),y(5,9,11);cout x. sum() y. sum()endl;15 25二、 寫出下列每個函數(shù)的功能1include include include void ja(char * fname) / /可以把fname所
14、指字符串作為文件標(biāo)識符的文件稱為fname文件ofstream fout(fname);char a20;cin a;whlie(strcmp(a,”end”)!=0)fout a a;將鍵盤輸入的字符串(上限為19個字符)寫入到fname文件中。2include include void jb(char * fname) / /可把以fname所指字符串作為文件標(biāo)識符的文件稱為fname文件 / /假定該文件中保存著一批字符串,每個字符串的長度均小于20。 ifstream fin(fname);char a20;int i = 0;whlie(fin a)cout a endl;i + +
15、;fin.close();cout ”i = ” i endl;將fname文件輸出到標(biāo)準(zhǔn)輸出流(屏幕)上,最后顯示字符串的數(shù)量。3include include void jc(chat * fname, int n) / /可把以fname所指字符串作為文件標(biāo)識符的文件稱為fname文件ofstream fout(fname, ios : : out | ios : : binary);int x;for(int i = 0;i x;fout.write(char * )&x, sizeof(x);fout.close();從鍵盤輸入n個數(shù),并以二進(jìn)制的方式寫到fname文件中。4incl
16、udeincludevoid jd(char * fname) / /可把以fname所指字符串作為文件標(biāo)識符的文件稱為fname文件, / /假定該文件保存著一批整數(shù)。ifstream fin(fname, ios : : in | ios : : nocreate | ios : : binary);int x, s = 0, n = 0;whlie(fin.read(char * )&x, sizeof(x)s + = x;n + +;cout n s float(s)/nendl;fin.close();輸出fname文件中保存的整數(shù)的個數(shù)、總加值以及平均值。if we dont do
17、 that it will go on and go on. we have to stop it; we need the courage to do it.his comments came hours after fifa vice-president jeffrey webb - also in london for the fas celebrations - said he wanted to meet ivory coast international toure to discuss his complaint.cska general director roman babae
18、v says the matter has been exaggerated by the ivorian and the british media.blatter, 77, said: it has been decided by the fifa congress that it is a nonsense for racism to be dealt with with fines. you can always find money from somebody to pay them.it is a nonsense to have matches played without sp
19、ectators because it is against the spirit of football and against the visiting team. it is all nonsense.we can do something better to fight racism and discrimination.this is one of the villains we have today in our game. but it is only with harsh sanctions that racism and discrimination can be washe
20、d out of football.the (lack of) air up there watch mcayman islands-based webb, the head of fifas anti-racism taskforce, is in london for the football associations 150th anniversary celebrations and will attend citys premier league match at chelsea on sunday.i am going to be at the match tomorrow and
21、 i have asked to meet yaya toure, he told bbc sport.for me its about how he felt and i would like to speak to him first to find out what his experience was.uefa hasopened disciplinary proceedings against cskafor the racist behaviour of their fans duringcitys 2-1 win.michel platini, president of euro
22、pean footballs governing body, has also ordered an immediate investigation into the referees actions.cska said they were surprised and disappointed by toures complaint. in a statement the russian side added: we found no racist insults from fans of cska.baumgartner the disappointing news: mission abo
23、rted.the supersonic descent could happen as early as sunda.the weather plays an important role in this mission. starting at the ground, conditions have to be very calm - winds less than 2 mph, with no precipitation or humidity and limited cloud cover. the balloon, with capsule attached, will move th
24、rough the lower level of the atmosphere (the troposphere) where our day-to-day weather lives. it will climb higher than the tip of mount everest (5.5 miles/8.85 kilometers), drifting even higher than the cruising altitude of commercial airliners (5.6 miles/9.17 kilometers) and into the stratosphere.
25、 as he crosses the boundary layer (called the tropopause),e can expect a lot of turbulence.the balloon will slowly drift to the edge of space at 120,000 feet ( then, i would assume, he will slowly step out onto something resembling an olympic diving platform.below, the earth becomes the concrete bot
26、tom of a swimming pool that he wants to land on, but not too hard. still, hell be traveling fast, so despite the distance, it will not be like diving into the deep end of a pool. it will be like he is diving into the shallow end.skydiver preps for the big jumpwhen he jumps, he is expected to reach the speed of sound - 690 mph (1,110 kph) -
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 《沙盤規(guī)則介紹》課件
- 《定價的基本策略》課件
- 安全生產(chǎn)月基本知識培訓(xùn)116
- 《紅樓夢導(dǎo)讀》課件
- 圖像上傳隱私保護(hù)-洞察分析
- 《網(wǎng)絡(luò)安全發(fā)展jinm》課件
- 體育器械安全性能評估-洞察分析
- 系統(tǒng)動力學(xué)建模-第1篇-洞察分析
- 胎兒水腫基因組關(guān)聯(lián)分析-洞察分析
- 語言瀕危與社會責(zé)任-洞察分析
- 手消毒液使用率低品管圈課件
- 偏身舞蹈癥的護(hù)理查房
- 抑郁障礙患者的溝通技巧課件
- 技術(shù)成果轉(zhuǎn)移案例分析報告
- 護(hù)理人才梯隊建設(shè)規(guī)劃方案
- 睡眠區(qū)布局設(shè)計打造舒適宜人的睡眠環(huán)境
- 建筑設(shè)計行業(yè)項目商業(yè)計劃書
- 慢性病防治健康教育知識講座
- 骶尾部藏毛疾病診治中國專家共識(2023版)
- 【高新技術(shù)企業(yè)所得稅稅務(wù)籌劃探析案例:以科大訊飛為例13000字(論文)】
- 幽門螺旋桿菌
評論
0/150
提交評論