C++常见英文面试笔试题Word格式文档下载.docx

上传人:b****2 文档编号:13890037 上传时间:2022-10-14 格式:DOCX 页数:17 大小:205.86KB
下载 相关 举报
C++常见英文面试笔试题Word格式文档下载.docx_第1页
第1页 / 共17页
C++常见英文面试笔试题Word格式文档下载.docx_第2页
第2页 / 共17页
C++常见英文面试笔试题Word格式文档下载.docx_第3页
第3页 / 共17页
C++常见英文面试笔试题Word格式文档下载.docx_第4页
第4页 / 共17页
C++常见英文面试笔试题Word格式文档下载.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

C++常见英文面试笔试题Word格式文档下载.docx

《C++常见英文面试笔试题Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《C++常见英文面试笔试题Word格式文档下载.docx(17页珍藏版)》请在冰豆网上搜索。

C++常见英文面试笔试题Word格式文档下载.docx

WhatisPolymorphism?

Polymorphismallowsaclienttotreatdifferent

tomembercopy(shallowcopy)

Whatarealltheimplicitmemberfunctionsoftheclass?

Orwhatareallthefunctionswhichcompilerimplementsforusifwedon'

tdefineone.?

defaultctor

copyctor

assignmentoperator

defaultdestructor

addressoperator

Whatisconversionconstructor?

constructorwithasingleargumentmakesthatconstructorasconversionctoranditcanbeusedfortypeconversion.

forexample:

classBoo

{

public:

Boo(inti);

};

BooBooObject=10;

//assigningint10Booobject

Whatisconversionoperator?

classcanhaveapublicmethodforspecificdatatypeconversions.

doublevalue;

Boo(inti)

operatordouble()

{

returnvalue;

}

BooBooObject;

doublei=BooObject;

//assigningobjecttovariableioftypedouble.nowconversionoperatorgetscalledtoassignthevalue.

Whatisdiffbetweenmalloc()/free()andnew/delete?

mallocallocatesmemoryforobjectinheapbutdoesn'

tinvokeobject'

sconstructortoinitiallizetheobject.

newallocatesmemoryandalsoinvokesconstructortoinitializetheobject.

malloc()andfree()donotsupportobjectsemantics

Doesnotconstructanddestructobjects

string*ptr=(string*)(malloc(sizeof(string)))

Arenotsafe

Doesnotcalculatethesizeoftheobjectsthatitconstruct

Returnsapointertovoid

int*p=(int*)(malloc(sizeof(int)));

int*p=newint;

Arenotextensible

newanddeletecanbeoverloadedinaclass

"

delete"

firstcallstheobject'

sterminationroutine(i.e.itsdestructor)andthenreleasesthespacetheobjectoccupiedontheheapmemory.Ifanarrayofobjectswascreatedusingnew,thendeletemustbetoldthatitisdealingwithanarraybyprecedingthenamewithanempty[]:

-

Int_t*my_ints=newInt_t[10];

...

delete[]my_ints;

whatisthediffbetween"

new"

and"

operatornew"

?

workslikemalloc.

Whatisdifferencebetweentemplateandmacro?

Thereisnowayforthecompilertoverifythatthemacroparametersareofcompatibletypes.Themacroisexpandedwithoutanyspecialtypechecking.

Ifmacroparameterhasapost-incrementedvariable(likec++),theincrementisperformedtwotimes.

Becausemacrosareexpandedbythepreprocessor,compilererrormessageswillrefertotheexpandedmacro,ratherthanthemacrodefinitionitself.Also,themacrowillshowupinexpandedformduringdebugging.

Macro:

#definemin(i,j)(i<

j?

i:

j)

template:

template<

classT>

Tmin(Ti,Tj)

{

returni<

j;

}

WhatareC++storageclasses?

auto

register

static

extern

auto:

thedefault.Variablesareautomaticallycreatedandinitializedwhentheyaredefinedandaredestroyedattheendoftheblockcontainingtheirdefinition.Theyarenotvisibleoutsidethatblock

register:

atypeofautovariable.asuggestiontothecompilertouseaCPUregisterforperformance

static:

avariablethatisknownonlyinthefunctionthatcontainsitsdefinitionbutisneverdestroyedandretains=keepitsvaluebetweencallstothatfunction.Itexistsfromthetimetheprogrambeginsexecution

extern:

astaticvariablewhosedefinitionandplacementisdeterminedwhenallobjectandlibrarymodulesarecombined(linked)toformtheexecutablecodefile.Itcanbevisibleoutsidethefilewhereitisdefined.

WhatarestoragequalifiersinC++?

Theyare..

const

volatile

mutable

Constkeywordindicatesthatmemoryonceinitialized,shouldnotbealteredbyaprogram.

volatilekeywordindicatesthatthevalueinthememorylocationcanbealteredeventhoughnothingintheprogram

codemodifiesthecontents.forexampleifyouhaveapointertohardwarelocationthatcontainsthetime,wherehardwarechangesthevalueofthispointervariableandnottheprogram.Theintentofthiskeywordtoimprovetheoptimizationabilityofthecompiler.

mutablekeywordindicatesthatparticularmemberofastructureorclasscanbealteredevenifaparticularstructurevariable,class,orclassmemberfunctionisconstant.

struct

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 工学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1