2014年計(jì)算機(jī)等級(jí)二級(jí)C++上機(jī)考試沖刺試題

字號(hào):

為大家收集整理了《2014年計(jì)算機(jī)等級(jí)二級(jí)C++上機(jī)考試沖刺試題》供大家參考,希望對(duì)大家有所幫助?。?!
    1、有如下程序:
    #include
    using namespace std;
    class Base{
    protected:
    Base(){cout<<’A’;}
    Base(char C){cout< };
    class Derived:public Base{
    public:
    Derived(char C){tout< };
    int main(){
    Derived dl(’B’);
    retum 0;
    }
    執(zhí)行這個(gè)程序的輸出結(jié)果是( ?。?。
    A.B
    B.BA
    C.AB
    D.BB
    2、下列符號(hào)中能夠作為C++標(biāo)識(shí)符的是( )。
    A.Coflst
    B.2a
    C._shape
    D..Count
    3、有如下程序:
    #include
    using namespace std;
    class Base
    {
    private:
    void funl()const{tout<<”funl”;}
    protected:
    void fun2()const{tout<<”fun2”;}
    public:
    void fun3()const{cout<<”fhll3”;}
    };
    class Derived:protected Base
    {
    public:
    void fhn4()const{cout<<”filn4”;}
    };
    int main()
    {
    Derived obj;
    obj.funl();//①
    obj.fun2();//②
    obj.furd();//③
    obj.fun4();//④
    return U:
    }
    其中有語(yǔ)法錯(cuò)誤的語(yǔ)句是( ?。?BR>    A.①②③④
    B.①②③
    C.②③④
    D.①④
    4、有如下程序:
    #include
    using namespace std;
    class Instrument{
    public:
    virtual void Display()=0;
    };
    class Pian0:public Instrument}
    public:
    void Display(){/*函數(shù)體略*/}
    };
    intmain(){
    Instrument S;
    Instrument*P=0:
    //…;
    return 0;
    }
    下列敘述中正確的是( ?。?BR>    A.語(yǔ)句“Insturment*P=0;”編譯時(shí)出錯(cuò)
    B.語(yǔ)句“Instnunent s;”編譯時(shí)出錯(cuò)
    C.類Pian0中的Display函數(shù)不是虛函數(shù)
    D.類Instrument是一個(gè)虛基類
    5、如下函數(shù)模板:
    templateT square(T x){return x*x;} 其中T是( ?。?。
    A.函數(shù)形參
    B.函數(shù)實(shí)參
    C.模板形參
    D.模板實(shí)參
    6、為了提高函數(shù)調(diào)用的實(shí)際運(yùn)行速度,可以將較簡(jiǎn)單的函數(shù)定義為( )。
    A.內(nèi)聯(lián)函數(shù)
    B.重載函數(shù)
    C.遞歸函數(shù)
    D.函數(shù)模板
    7、有如下程序:
    #inClude using namespaCe std; Class Point{
    publiC:
    statiC int number;
    publiC:
    Point( ?。﹖.number++;} ~Point( ?。﹞number--;}
    }; , int P0int::number=0;
    int main( ?。﹞
    Point *ptr:
    Point A,B; Point*ptr_point=new Point[3]; ptr=ptr_point;’
    }
    Point C;
    Cout< return 0; }
    執(zhí)行這個(gè)程序的輸出結(jié)果是( ?。?。
    A.3
    B.4
    C.6
    D.7