单选题
下面程序的输出结果是( )。 #include
class example { int a; public: example(int b){a=b++;} void print(){a=a+1;cout<
A、
2 2
B、
4 3
C、
4 2
D、
3 2
【正确答案】
C
【答案解析】
解析:“++”是右结合的,所以先赋值为3,最后输出3+1;常成员函数只有常对象才能调用,所以输出2。
提交答案
关闭