资源描述:
《c 面向对象程序设计模拟试题(c object oriented programming simulation questions )》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、c++面向对象程序设计模拟试题4(C++objectorientedprogrammingsimulationquestions4)C++objectorientedprogrammingsimulationquestionsfourAsinglechoice(thetitleof10items,eachitemof2points,atotalof20points)inthefouroptionofeachitemlisted,onlyoneisinlinewiththerequirementsofthesubject,pleasefillinthecodei
2、nquestionafterthebrackets.Thewrongchoiceornot,choosenopoints.@@@1.inthefollowingstatementabouttheC++function,whatiscorrectis(C).A)aninlinefunctionisafunctiondefinedwithinanotherfunctionbodyB)thelaststatementofthebodyofthefunctionmustbethereturnstatement(C)beforecallingafunction,youm
3、ustdeclareitsprototypeifithasnotbeendefinedD)thecompilerdistinguishesthedifferentoverloadedformsofthefunctionbasedonthereturntypeofthefunctionandtheparametertable2.assumethatMyCIassisaclass,thenthefollowingfunctiondeclaration,(C)isthenoargumentconstructoroftheclass.(A)void,MyClass()
4、;B)~MyClass(int,n);C)MyClass();D)~MyClass();@@3.inthefollowingstatement,theerroris(C).A)derivedclassescanbederivedusingprivateB)accesstobaseclassmembersmustbenon-semantictwoC)theaccesscapabilityofabaseclassmemberremainsunchangedinaderivedclassD)theassignmentcompatibilityruleappliest
5、oacombinationofmultipleinheritance,too4.whenafunctionofaclassisspecifiedasvirtual,thesamefunctionastheprototypeofthisfunctionisinthatclassandallitsderivedclasses(A).A.isavirtualfunction,andB.isavirtualfunctiononlywhenitisrestatedasvittualC.isnotavirtualfunction,andD.isnottrueonitAme
6、mberofan@@5.derivedclassconstructorthatcannotbeincludedintheinitializationtable(C).A)thebaseclassconstructorB)derivestheinitializationofaclassofneutronobjects(C)initializationofclassneutronobjectsD)theinitializationofthegeneraldatamembersinthederivedclass6.hereisafunctionalprototype
7、declarationoftheoverloadedadditionoperator,inwhichtheerroris(A).A)MyClassoperator+(double,double);B)MyClassoperator+(double,MyClass);C)MyClassoperator+(MyClass,double);D)MyClassoperator+(MyClass,MyClass);7.membersinaderivedclasscannotdirectlyaccess(B)membersinthebaseclass.(A)publicB
8、)privateC)virtualD)