有如下类定义: class Test { public: Test(){a=0;C=0;} ∥① int f(int a)const{this.>a:a;} ∥② static int g(){r

admin2020-07-30  17

问题 有如下类定义:
    class Test
    {
    public:
    Test(){a=0;C=0;}    ∥①
    int f(int a)const{this.>a:a;}    ∥②
    static int g(){return a;)    ∥③
    void h(int b){Test::b=b;};    ∥④
    private:
    int a;
    static int b;
    const int c;
    );
    int Test::b=0:
    在标注号码的行中,能被正确编译的是(    )。

选项 A、①
B、②
C、③
D、④

答案D

解析 此题考查的是类的定义。一个类的长数据成员的初始化只能在成员初始化列表中进行,故选项A错误;常成员函数不能更新对象的数据成员,故选项B错误;静态成员函数可以直接访问类中说明的静态成员,但不能直接访问类中说明的非静态成员,故选项C错误。
转载请注明原文地址:https://kaotiyun.com/show/FTyp777K
0

最新回复(0)