单选题 C++
题号 #2250864

有如下程序:
#include<iostream>
usingnamespacestd;
classA{
public:
A(inti):rl(i){)
voidprint(  ){cout<<'E'<<r1<<'-';)
voidprint(  )const{cout<<'C'<<r1*r1<<'-';}
private:
intr1:
};
intmain(  ){
Aal(2);constAa2(4);,
al.print(  );a2.print(  );
return0;
}
运行时的输出结果是(  )。

进入在线模考

参考答案

B

答案解析

B。【解析】const关键字可以用于参与对重载函数的区分。重载的原则是常对象调用常成员函数,一般对象调用一般成员函数。

你可能感兴趣的试题

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