![電大形成性考核冊(cè)c++第四次作業(yè)及答案_第1頁](http://file2.renrendoc.com/fileroot_temp3/2021-7/11/447fbdec-b00f-4feb-9675-94eecf52b8d6/447fbdec-b00f-4feb-9675-94eecf52b8d61.gif)
![電大形成性考核冊(cè)c++第四次作業(yè)及答案_第2頁](http://file2.renrendoc.com/fileroot_temp3/2021-7/11/447fbdec-b00f-4feb-9675-94eecf52b8d6/447fbdec-b00f-4feb-9675-94eecf52b8d62.gif)
![電大形成性考核冊(cè)c++第四次作業(yè)及答案_第3頁](http://file2.renrendoc.com/fileroot_temp3/2021-7/11/447fbdec-b00f-4feb-9675-94eecf52b8d6/447fbdec-b00f-4feb-9675-94eecf52b8d63.gif)
![電大形成性考核冊(cè)c++第四次作業(yè)及答案_第4頁](http://file2.renrendoc.com/fileroot_temp3/2021-7/11/447fbdec-b00f-4feb-9675-94eecf52b8d6/447fbdec-b00f-4feb-9675-94eecf52b8d64.gif)
![電大形成性考核冊(cè)c++第四次作業(yè)及答案_第5頁](http://file2.renrendoc.com/fileroot_temp3/2021-7/11/447fbdec-b00f-4feb-9675-94eecf52b8d6/447fbdec-b00f-4feb-9675-94eecf52b8d65.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、專業(yè)好文檔計(jì)算機(jī)應(yīng)用專業(yè)“c+語言程序設(shè)計(jì)”課程作業(yè)第四次作業(yè)一、 填空題1. 在定義類對(duì)象的語句執(zhí)行時(shí),系統(tǒng)在建立每個(gè)對(duì)象的過程中將自動(dòng)調(diào)用該類的_構(gòu)造函數(shù)_使其初始化。2. 當(dāng)一個(gè)類對(duì)象被撤消時(shí)將自動(dòng)調(diào)用該類的_析構(gòu)函數(shù)_。3. 對(duì)基類數(shù)據(jù)成員的初始化是通過執(zhí)行派生類構(gòu)造函數(shù)中的_初始化表_來實(shí)現(xiàn)的。4. 對(duì)一個(gè)類中的數(shù)據(jù)成員的初始化可以通過構(gòu)造函數(shù)中的_初始化表_實(shí)現(xiàn),也可以通過構(gòu)造函數(shù)中的_賦值語句_實(shí)現(xiàn)。5. 在一個(gè)派生類中,對(duì)基類成員、類對(duì)象成員和非類對(duì)象成員的初始化次序的先基類成員,后類對(duì)象成員,最后非對(duì)象成員。6. 當(dāng)撤消一個(gè)含有基類和類對(duì)象成員的派生類對(duì)象時(shí),將首先完成派生類
2、本身的析構(gòu)函數(shù)定義體的執(zhí)行,接著完成類對(duì)象成員的析構(gòu)函數(shù)定義體的執(zhí)行,最后完成基類成員的析構(gòu)函數(shù)定義體的執(zhí)行。7. 設(shè)px是指向一個(gè)類動(dòng)態(tài)對(duì)象的指針變量,則執(zhí)行“delete px;”語句時(shí),將自動(dòng)調(diào)用該類的析構(gòu)函數(shù)。8. 當(dāng)一個(gè)類對(duì)象離開它的作用域時(shí),系統(tǒng)將自動(dòng)調(diào)用該類的析構(gòu)函數(shù)。9. 假定一個(gè)類對(duì)象數(shù)組為an,當(dāng)離開它的作用域時(shí),系統(tǒng)自動(dòng)調(diào)用該類析構(gòu)函數(shù)的次數(shù)為n次。10. 假定ab為一個(gè)類,則執(zhí)行“ab a10;”語句時(shí),系統(tǒng)自動(dòng)調(diào)用該類構(gòu)造函數(shù)的次數(shù)為10次。11. 假定擁護(hù)沒有給一個(gè)名為ab的類定義構(gòu)造函數(shù),則系統(tǒng)為其隱含定義的構(gòu)造函數(shù)為空構(gòu)造函數(shù)。12. 假定用戶沒有給一個(gè)名為ab
3、的類定義析構(gòu)函數(shù),則系統(tǒng)為其隱含定義的析構(gòu)函數(shù)為空析構(gòu)函數(shù)。13. 若需要把一個(gè)函數(shù)“void f(); ”定義為一個(gè)類ab的友元函數(shù),則應(yīng)在類ab的定義中加入一條語句:friend void f();。14. 若需要把一個(gè)類ab定義為一個(gè)類cd的友元類,則應(yīng)在類cd的定義中加入一條語句:friend class ab;。15. 假定一個(gè)類ab中有一個(gè)靜態(tài)整型成員bb,在類外為它進(jìn)行定義并初始化為0時(shí),所使用寫法為ab:bb = 0;。16. 假定類ab中有一個(gè)公用屬性的靜態(tài)數(shù)據(jù)成員bb,在類外不通過對(duì)象名訪問該成員 bb的寫法為ab:bb。17. 當(dāng)類中一個(gè)字符指針成員指向具有n個(gè)字節(jié)的儲(chǔ)存
4、空間時(shí),它所能儲(chǔ)存字符串的最大長度為n-1。18. 假定ab為一個(gè)類,則該類的拷貝構(gòu)造函數(shù)的聲明語句為ab:ab(ab &)。19. 對(duì)類對(duì)象成員初始化是通過執(zhí)行構(gòu)造函數(shù)中的初始化表完成的。20. 對(duì)于類中定義的成員,其隱含訪問權(quán)限為private,對(duì)于結(jié)構(gòu)中定義的成員,其隱含訪問權(quán)限為public。21. 一個(gè)類的友元函數(shù)或友元類能夠通過成員操作符訪問該類的所有數(shù)據(jù)成員和函數(shù)成員。22. 假定要對(duì)類ab定義加號(hào)操作符重載成員函數(shù),實(shí)現(xiàn)兩個(gè)ab類對(duì)象的加法,并返回相加結(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)從字符文件中讀取回車和換行兩個(gè)字符時(shí),被系統(tǒng)看作為一個(gè)換行符。28. 當(dāng)使用ifstream流類定義一個(gè)流對(duì)象并打開一個(gè)磁盤文件時(shí),文件的隱含打開方式為 讀取的文本文件,當(dāng)使用ofstream 流類定義一個(gè)流對(duì)象并打開一個(gè)磁盤文件時(shí),文件的隱含打開方式為寫入的文本文件。29. 當(dāng)需要使用ist
6、rstream流類定義一個(gè)流對(duì)象并聯(lián)系一個(gè)字符串時(shí),應(yīng)在文件開始使用#include命令,使之包含strstrea.h文件。二給出下列程序運(yùn)行后的輸出結(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二、 寫出下列每個(gè)函數(shù)的功能1include include include void ja(char * fname) / /可以把fname所
14、指字符串作為文件標(biāo)識(shí)符的文件稱為fname文件ofstream fout(fname);char a20;cin a;whlie(strcmp(a,”end”)!=0)fout a a;將鍵盤輸入的字符串(上限為19個(gè)字符)寫入到fname文件中。2include include void jb(char * fname) / /可把以fname所指字符串作為文件標(biāo)識(shí)符的文件稱為fname文件 / /假定該文件中保存著一批字符串,每個(gè)字符串的長度均小于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)識(shí)符的文件稱為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個(gè)數(shù),并以二進(jìn)制的方式寫到fname文件中。4incl
16、udeincludevoid jd(char * fname) / /可把以fname所指字符串作為文件標(biāo)識(shí)符的文件稱為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ù)的個(gè)數(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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 建筑工程樁基合同
- 個(gè)人魚塘合同范本
- 制作安裝項(xiàng)目合同范本
- 農(nóng)資代理合同范例
- 2025年度農(nóng)業(yè)科技研發(fā)與應(yīng)用合同范本
- 公司人事調(diào)動(dòng)合同范例
- 凈水器保修合同范例
- 輸入模塊行業(yè)市場發(fā)展及發(fā)展趨勢與投資戰(zhàn)略研究報(bào)告
- 勞動(dòng)合同范本2012
- 業(yè)務(wù)合作勞務(wù)合同范本
- 2025年湖南九嶷職業(yè)技術(shù)學(xué)院高職單招職業(yè)技能測試近5年??及鎱⒖碱}庫含答案解析
- 農(nóng)產(chǎn)品貯運(yùn)與加工考試題(附答案)
- 幼兒園開學(xué)教職工安全教育培訓(xùn)
- 學(xué)校財(cái)務(wù)年終工作總結(jié)4
- 生態(tài)安全課件
- 鋼鐵是怎樣煉成的鋼鐵讀書筆記
- 2025年汽車加氣站作業(yè)人員安全全國考試題庫(含答案)
- 化工過程安全管理導(dǎo)則安全儀表管理課件
- 中國高血壓防治指南-解讀全篇
- 2024年監(jiān)控安裝合同范文6篇
- 2024年山東省高考政治試卷真題(含答案逐題解析)
評(píng)論
0/150
提交評(píng)論