单选题 C++
题号 #2255341

有如下类定义:
classSample{
public:
Sample(intx):ref(x){}//①
private:
Sample():ref(0){}//②
staticintva1=5;//③
constintref;//④
};
上述程序段中,错误的语句是(  )。

进入在线模考

参考答案

C

答案解析

C。【解析】应为“staticconstintval一5;”,只有静态常量才可以初始化。

你可能感兴趣的试题

找试题 · 找答案 · 找资料 在线模考