C++基础题.docx
- 文档编号:26405558
- 上传时间:2023-06-19
- 格式:DOCX
- 页数:13
- 大小:20.89KB
C++基础题.docx
《C++基础题.docx》由会员分享,可在线阅读,更多相关《C++基础题.docx(13页珍藏版)》请在冰豆网上搜索。
C++基础题
专业
班级
学号
姓名
教研室主任
(签字)
学院院长(系主任)
(签字)
大连交通大学试卷
课程()
课程性质(√必修)考试方式(√闭卷)
得分
PartIChoice.(Pleasechoosethecorrectanswer,marktheanswerinblank)(Totalquestions:
25,totalpoints:
50,2pointsperquestion.)
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
1.InC++language,whichwordisnotakeywordofC++________.
AintBconstCstaticDdata
2.ifwehave
intb=3;floatf=1.2;chars=’d’;
thenwhichexpressionisincorrect?
______
A.++bB.f--C.s++D.5++
3.whichisthecorrectdeclarationaboutpurevirtualfunction?
>
Avirtualintfunc(int);Bvoidfunc(int)=0;
Cvirtualvoidfunc()=0;Dvirtualvoidfunc(int){};
4.Ifwehave
constintx=8;
constinty=2;
intz=10;
constint*pi=&x;
Whichofthefollowingstatementisnotcorrect?
___________
Api=&z;B*pi=78;Cpi=&y;DC=*pi;
5.Afriendfunctionofaclasscanaccesswhichmemberoftheclass?
_______
A.privatemember B.protectedmember
C.publicmember D.allmembers
6.thedestructionfunctionoftheclassiscalledwhen____________?
A.theclassiscreated B.theobjectiscreated
C.theobjectisdeleted D.can’tbecalledautomatically
7.Derivedclass(派生类)objectcanaccesswhichitem_________
A.publicmemberofbaseclassthatbeprivatelyinherited
B.protectedmemberofbaseclassthatbeprotectedinherited.
C.publicmemberofbaseclassthatbeprotectedinherited.
D.publicmemberofbaseclassthatbepubliclyinherited
题号
一
二
三
四
五
六
七
八
总分
得分
8.Ifwehaveinti=16,thenwhichisthecorrectdefinitionforreference?
()
A.int&x=&i;B.int&x=i;C.int*x=i;D.int&x;
9.Therehavedefinitionssuchas:
inta[10],x,*pa;
pa=&a[0];
Thenwhichchoiceisnotequaltotheothers?
________
Ax=*pa;Bx=*(a+l);Cx=*(pa+1);Dx=a[1];
10.InC++language,whichfunctionisusedtorealizepolymorphism(多态)_________
AinlinefunctionBoverloadedfunction
CvirtualfunctionDtemplatefunction
11.whichdescription(描述)aboutcopy-constructorisnotcorrect____________.
Acopy-constructorcanbeoverloaded
Bcopy-constructor’snameisthesameasclass
Ccopy-constructor’argumentisthereferenceofaobjectofthesameclass
Dcopy-constructorisaspecialconstructor
12.whichstatementiscorrectaboutoverloadingfunction?
_________
A.overloadingfunctionmusthavedifferentreturnvalue.
B.overloadingfunctionmusthavedifferentnumberofargument.
C.overloadingfunctionmusthavedifferentargumentlist.
D.overloadingfunctioncanhavedifferentname.
13.ThereisadefinitionofclassFooasfollow:
classFoo{intbar;};
thendatamemberbarofFoois___________
A.publicdatamemberB.privatememberfunction
C.privatedatamemberD.protecteddatamember
14..Whenafunctioninoneclassisdecl.aredasvirtual,thefunctionwill()inallderivedclass.
A.allbevirtual
B.bevirtualonlywhenitisredeclared
C.bevirtualonlywhenitisredeclaredasvirtual
D.notbevirtual
15.Giventhestatementsuchas:
for(int x=0,y=0;!
x&&y<=5;y++)
HowmanytimestheForstatementwillexecute?
_____________
A.0 B.5 C.6 D.countless
考生注意:
考试时间120分钟试卷总分100分共5页第1页
专业
班级
学号
姓名
16.whichistheincorrectobjectdefinition?
()
classCircle
{public:
Circle(inta,intb=0){x=a;y=b;}
private:
intx,y;
};
A.Circleb1B.Circleb1(4)C.Circle(3,5);D.Circleb1(7,7);
17.Theoutputoftheprogramis______
#include
usingnamespacestd;
voidmain()
{inti=0;
while(i<=8)
{i++;
if(i%3==2){cout<
}
}
A25B36C258D369
18.Whichisthecorrectoutputoftheprogram_______
#include
classA
{ intnum;
public:
A(inti){num=i;}
A(A&a){num=a.num++;}
voidprint(){cout< voidmain() { Aa (1),b(a); a.print(); b.print();} A.11 B.12 C.21 D.22 19.Thereisafunctiontemplate(函数模板): template Tadd(Tx,Ty){returnx+y;} Thenwhichstatementisnotcorrect____________. Aadd<>(1,2);Badd Cadd(1.0,2);Dadd(1.0,2.0); 20.Whichistherunningresultoffollowingprogram? #include usingnamespacestd; voidfun(inti,int*j,int&k) { i+=*j; (*j)++; k=i+*j; } voidmain() { intx=1,y=2,z=2; fun(x,&y,z); cout<<"x="< } A.x=5y=4z=2B.x=3y=3z=6 C.x=2y=4z=5D.x=1y=3z=6 21.Whichistheoutputoftheprogram______ int&max(int&x,int&y){return(x>y? x: y);} voidmain() { intm=3,n=4; max(m,n)--; cout< } A.3,2B.2,3C.3,4D.3,3 22.ConsidertheclassBaseandDerived: classBase{ public: inti; protected: intj; private: intk; }; classDerived: publicBase{ public: fun(); }; WhichmembersoftheclassBasecanbeaccessedbyfun()? A.i,j,k;B.i,j;C.i;D.j,k; 共5页第2页 专业 班级 学号 姓名 23.theoutputoftheprogramis__________? #include classexample {inta; public: example(intb){a=b++;}
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C+ 基础