![](https://lstatic.shangxueba.com/sxbzda/h5/images/m_q_title.png)
请教:2013年9月全国计算机等级《二级C++》命题预测试卷一第1大题第25小题答案我觉的有问题
【题目描述】
下面程序的输出结果是()。
#include<iostream>
Usingnamespacestd;
ClassBase{
public:
Base(intx=O){cout<<x;
}
};
ClassDerived:publicBase{
public:Derved(intx=0{cout<<x;
}
private;
Baseval;
};
int main(){
Derivedd(1);
retrun0;
}
A.0
B.1
C.01
D.001
【我提交的答案】: D |
【参考答案与解析】: 正确答案:C |
C。【解析】++是右结合的,所以先赋值为3,最后输出3+1;常成员函数只有常对象才能调用,所以输出2。
![](https://lstatic.shangxueba.com/sxbzda/h5/images/tips_org.png)