全部题库 / C++ / 试题详情
单选题 C++
2013-08-06

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

A.①
B.②
C.③
D.④

参考答案

C

答案解析

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

你可能感兴趣的试题