


下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
PAGE15頁2014版試卷標(biāo)準(zhǔn)格式重慶大學(xué)《面向?qū)ο蟪绦?016—2017學(xué)年第1學(xué)期開課學(xué)院:計算機(jī)課程號:CST21101 考試日期:2017.1.4考試方式:題號一二三四五六七考試方式:題號一二三四五六七八九十總分得分弊作絕拒考試提示嚴(yán)禁隨身攜帶通訊工具等電子設(shè)備參加考試;考試提示嚴(yán)禁隨身攜帶通訊工具等電子設(shè)備參加考試;替他人考試、兩次及以上作弊等,屬嚴(yán)重作弊,開除學(xué)籍。、信守實誠、爭競平室公教試 SECTION1:ShortAnswerQuestions(40points,8pointseach)考
Whatispurevirtualfunction?Whatiscopyconstructor?
命題人:曾令秋、劉驥、楊廣超組題人:葛亮審題人:鄒東升命題時間:2016.12.20教務(wù)名 1. Pleasedescribetheroleofthe“class”. 5. Whatisfunctionobject? 處姓 制號學(xué)級 線年班、業(yè)專院學(xué) 2. DescribethekeycomponentsofSTL. SECTION2:AnalyzingandUnderstandingProgram(40points,10pointseach)PAGEPAGE55頁2014版試卷標(biāo)準(zhǔn)格式Pleasewritetheoutputresultofthefollowingprogram.#include<iostream>#include#include<numeric>usingnamespacestd;intmyFunction(intx,inty)returnx+2*y;}classMyObject{public:intoperator()(intx,inty){returnx+3*y;}}; 2.Pmain(){intinit=100;intnumbers[]={10,20,30};cout<<"usingdefaultaccumulate:";cout<<accumulate(numbers,numbers+3,init);cout<<'\n';cout<<"usingfunctional'sminus:";cout<<accumulate(numbers,numbers+3,init,minus<int>());cout<<'\n';cout<<"usingcustomfunction:";cout<<accumulate(numbers,numbers+3,init,myFunction);cout<<'\n';cout<<"usingcustomobject:";MyObjectobj;cout<<accumulate(numbers,numbers+3,init,obj);cout<<'\n';return0;
#include<iostream>usingnamespacestd;classSample{private:intpublic:Sample(){x=y=0;}Sample(inti,intj){x=i;y=j;}voidcopy(Sample&s);voidsetxy(inti,intj){x=i;y=j;}voidprint(){cout<<"x="<<x<<",y="<<y<<endl;}}};voidSample::copy(Sample&s){x=s.x;y=s.y;}
classA{voidfunc(Samples1,Sample&s2){s1.setxy(10,20);s2.setxy(30,40);}intmain(){Samplep(1,2),q;q.copy(p);func(p,q);p.print();q.print();return0;}
private:intpublic:A(intx):a(x){cout<<"AConstructor"<<endl;}voidShow()const{cout<<"A::a="<<a<<endl;}};classB:publicA{private:intpublic:B(intx,inty):A(x),b(y){cout<<"BConstructor"<<endl;}voidShow()const{cout<<"B::b="<<b<<endl;}};classC:publicA{private:intpublic:C(intx,inty):A(x),c(y){cout<<"CConstructor"<<endl;}voidShow()const{cout<<"C::c="<<c<<endl;}};intmain(){Pleasewritetheoutputresultofthefollowingprogram.
Bb(1,6);Cc(2,8);A*p=&c;p->Show();return0;Pleasefindouttheerrorsinthefollowingprogramandcorrectthem.#include<iostream>usingnamespace
#include<iostream>usingnamespaceclassA{public:A();A(A);A&operator=(constA&r);intoperator[](intindex);friendconstAoperator+(A&r1,A& r2);friendostream&operator<<(ostream&,constA&);private:intarr[10];};
intA::operator[](intindex){returnarr[index];}ostream&operator<<(ostream&output,constA&r){for(inti=0;i<10;i++)output<<r.arr[i]<<"";returnoutput;}intmain(){A::A()Aa1,a2,a3;{a3=a1+a2;for(inti=0;i<10;i++)a3[3]=7;arr[i]=i;cout<<a3;}A::A(Aarray)return0;{}for(inti=0;i<10;i++)arr[i]=array.arr[i];}A&A::operator=(constA&r){for(inti=0;i<10;i++)arr[i]=r.arr[i];returnthis;}constAoperator+(A&r1,A&r2){Are;for(inti=0;i<10;i++)re[i]=r1[i]+r2[i];returnre;}
SECTION3:Writetheprogramtosolvethefollowingproblem.(20points,20pointseach)CreateaninheritancehierarchythatcontainingabaseclassFilmandtwoderivedclassesFilm2DandFilm3D.ThebaseclassFilmshouldincludeadatamemberoftypestringtorepresentthefilmnameandadatamemberoftypefloattorepresentthefilmduration.Youshoulddesigntheconstructortoinitialthetwodatamembers.AndthereshouldbeapurevirtualfunctionnamedseeFilm.DerivedclassFilm2DshouldinheritthefunctionalityoftheFilm.Butalsoincludeadatamemberoftypeinttorepresentthefilmhall(電影廳).YouimplementtheconstructorandthevirtualfunctionseeFilm.DerivedclassFilm3DshouldalsoinheritthefunctionalityoftheFilm.andincludeanadditionaldatamemberoftypeinttorepresentthefilmprivateroom(電影包房).Youalsoshouldimplementtheconstructorandthevirtualfunc
溫馨提示
- 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 中國高等教育發(fā)展歷程
- 期末復(fù)習(xí)勝略指南
- 使用固定總價合同范例
- 上海租賃和合同范例
- 個人游戲代理合同范本
- 垃圾分類改造施工方案
- 產(chǎn)品買賣簡易合同范例
- 旅游業(yè)持續(xù)發(fā)展探析
- 與員工簽訂五險合同范例
- 心理危機(jī)預(yù)防
- 幼兒園食譜播報
- 公路養(yǎng)護(hù)服務(wù)投標(biāo)方案(技術(shù)標(biāo))
- 灌入式半柔性復(fù)合抗車轍路面施工工法
- 小班第一學(xué)期教學(xué)進(jìn)度表
- 材料性能學(xué)課件:材料的熱學(xué)性能-2-熱傳導(dǎo)-熱穩(wěn)定性-
- 幼兒園優(yōu)質(zhì)公開課:中班數(shù)學(xué)《尋寶小勇士》課件
- 監(jiān)理單位工程項目總監(jiān)及監(jiān)理人員名冊
- 北師大版小學(xué)英語3-6年級單詞-(三起)帶音標(biāo)-精華版
- 聲樂第2版(學(xué)前教育專業(yè))PPT完整全套教學(xué)課件
- 《鐵道工程(A)》課程大綱
- 鼻飼老年人進(jìn)食照護(hù)-鼻飼的定義和適應(yīng)人群
評論
0/150
提交評論