IKM-C++2new

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

IKMC++AssessmentC++PROGRAMMINGIfyouloseyourinternetconnection,youwillbeabletoresumethetestatthepointatwhichitwasinterrupted.Simplycloseyourbrowserwindow(s)usingtheAltandF4keys,reconnectyourinternetconnectionandlogbackonusingtheaboveURLandpassword(priortothetestexpirationdateandtime).Forotherhelpfulhints,seeourTechnicalSupportTips(whichweencourageyoutoprintoutbeforeyoubeginthetest).Youmustcompletetheseassessmentsby2009/01/2721:16EST.Afterthistime,thepasswordswillnolongerwork,andyouwillneedtocontactyourtestadministratortogetnewworkingpasswords.Goodluck!IKMAssessmentAdministrationRef:Question4:WhichofthefollowingstatementscorrectlydescribethecodebelowinC++?#definelanguage437//Line1#iflanguage400#undeflanguage//Line2#else//Line3#definelanguage850//Line4#ifdeflanguage//Line5printf(%d,language);//Line6#endif#endifA.AnerrororwarningwilloccuronLine6becauseamacrocannotbeusedaspartofapreprocessordirective.B.AnerrororwarningwilloccuronLine2because#undefisnotavalidpreprocessordirective.C.AnerrororwarningwilloccuronLine4becauselanguagehasalreadybeendefined.D.IfLine1ischangedto#definelanguage300,Line6willprint850.E.AnerrororwarningwilloccuronLine3because#elsecanonlybeusedasthelastconditionalinthechain.Answer:DQuestion5:Whichofthefollowingstatementsregardingthebenefitsofusingtemplatefunctionsoverpreprocessor#definemacrosarecorrect?A.Apreprocessormacroexpansioncannotworkwhenuser-definedtypesarepassedtoitasarguments.B.Sincethepreprocessordoesthemacroexpansionandnotthecompiler,thebuildprocesstakesalongerperiodoftime.C.Whileexpanding#definemacros,thepreprocessordoesnotypecheckingontheargumentstothemacro.D.Apreprocessormacroexpansionincursaperformanceoverheadatruntime.E.Itissimpletostepintoatemplatefunctioncodeduringthedebuggingprocess.Answer:EQuestion6:WhichofthefollowingarecontaineradaptersintheSTL(StandardTemplateLibrary)inC++?A.listB.mapC.stackD.queueE.dequeAnswer:CDQuestion7:Whichofthefollowingcorrectlyidentifybenefitsofthegetline()memberfunctionforcinovertheextractionoperatorinC++?A.Thegetline()functionbydefault,acceptswhitespace,andreturnsonseeingthe\ncharacter,whereastheextractionoperatorreturnswhenitencountersanywhitespacecharacter.B.Delimitersindicatingendofinputcanbespecifiedtothegetline()function,whereastheextractionoperatorhasnosuchfacility.C.Thegetline()functioncanbeoverloadedtoacceptdifferentargumenttypes,whereastheextractionoperatorcannotbeoverloaded.D.Thenumberofbytestoreadcanbespecifiedtothegetline()function,whereasitcannotbedonewiththeextractionoperator.E.Thegetline()functioncanbeusedlikeamanipulatorwithcin,whereastheextractionoperatorcannotbeusedasamanipulator.Question8:InwhichofthefollowingscenariosisaCopyConstructorcalledorinvoked?A.WhennoconversionfunctionexistsforconvertingtheclassobjecttoanotherclassobjectB.WhenanexistingobjectisassignedanobjectofitsownclassC.Whenafunctionreceivesasanargument,anobjectoftheclass,byvalueD.WhenafunctionreturnsanobjectoftheclassbyvalueE.WhencreatinganobjectandinitializingitwithanobjectofitsownclassAnswer:BCDEQuestion9:WhichofthefollowingstatementscorrectlydescribetheresultsofexecutingthecodebelowinC++?#includeiostreamusingnamespacestd;classExBase{private:staticintstat;public:staticintGetStat(){returnstat;}};intExBase::stat=25;classExDer1:publicExBase{public:friendintDer1Fn(){returnExBase::stat;}};classExDer2:publicExBase{};classExDer:publicExDer1,publicExDer2{};A.intmain(){ExDerd;coutd.Der1Fn()endl;}willresultinanambiguityerrorfromthecompiler.B.intmain(){ExDerd;coutd.GetStat()endl;}willdisplayanoutputas25.C.intmain(){coutExDer1::GetStat()endl;}willresultinanambiguityerrorfromthecompiler.D.classExDer1:publicExBase{public:friendintDer1Fn(){returnExBase::stat;}};willresultinanaccesserrorfromthecompiler.E.intmain(){coutExDer1::ExBase::GetStat()endl;}willdisplayanoutputas25.Question10:Giventhefollowingprogramsnippet,whatcanweconcludeabouttheuseofdynamic_castinC++?#includeiostream#includememory//Someoneelse'scode,e.g.libraryclassIGlyph{public:virtual~IGlyph(){}virtualstd::stringText()=0;virtualIIcon*Icon()=0;//...};classIWidgetSelector{public:virtual~IWidgetSelector(){}virtualvoidAddItem(IGlyph*)=0;virtualIGlyph*Selection()=0;};//YourcodeclassMyItem:publicIGlyph{public:virtualstd::stringText(){returnthis-text;}virtualIIcon*Icon(){returnthis-icon.get();}voidActivate(){std::coutMyItemActivatedstd::endl;}std::stringtext;std::auto_ptrIIconicon;};voidSpiffyForm::OnDoubleClick(IWidgetSelector*ws){IGlyph*gylph=ws-Selection();MyItem*item=dynamic_castMyItem*(gylph);if(item)item-Activate();}A.Thedynamic_castoughttobeareinterpret_castsincetheconcretetypeisunknown.B.Thedynamic_castisunnecessarysinceweknowthattheconcretetypereturnedbyIWidgetSelector::Selection()mustbeaMyItemobject.C.Thedynamic_castisredundant,theprogrammercaninvokeActivatedirectly,e.g.ws-Selection()-Activate();D.Thedynamic_castisnecessarysincewecannotknowforcertainwhatconcretetypeisreturnedbyIWidgetSelector::Selection().E.Apolymorphic_castshouldbeusedin

1 / 26
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功