有如下类定义: class Sample{ public; Sample(int x):ref(x){} //① private: Sample():ref(0){} //② sta

admin2016-11-25  27

问题 有如下类定义:
    class Sample{
    public;  
        Sample(int x):ref(x){}  //①
    private:
        Sample():ref(0){}       //②
static int val=5;    //③
    const int ref;     //④  
    };
    上述程序段中,错误的语句是(    )。

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

答案C

解析 静态整型数据不能定义为类的数据成员。
转载请注明原文地址:https://kaotiyun.com/show/bEAp777K
0

最新回复(0)