首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class sample { private: int x,y: public: sample(int i.int j)
有如下程序: #include using namespace std; class sample { private: int x,y: public: sample(int i.int j)
admin
2020-07-23
45
问题
有如下程序:
#include
using namespace std;
class sample
{
private:
int x,y:
public:
sample(int i.int j)
{
X=I:
y=1:
}
void disp()
{
cout<<7”disp l”<
}
void dispoconst
{
cout<<“disp2”<
}
}:
int main()
{
const sample a(1,2);
a.dispo;
return 0:
}
该程序运行后的输出结果是( )
选项
A、displ
B、disp2
C、disp1 disp2
D、程序编译时出错
答案
B
解析
因为对象a被定义为常对象,所以a.disp()语句调用的是类的常成员函数voiddisp()const,输出的结果是disp2。
转载请注明原文地址:https://kaotiyun.com/show/c9yp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列函数模板的定义中,合法的是()。
必须用一对大括号括起来的程序段是()。
有如下程序段:inti=0,j=1;nt&r=i;//①r=j;//②int*p=&i;//③*p=&r;//④其中会产生编译错误的语句是(
有如下程序:#includeusingnamespacestd;intmain(){intf,f1=1,f2=1;for(inti=0;i
下列关于模板的表述中,正确的是
下列关于模板的表述中,正确的是
下列关于函数模板的表述中,正确的是
下列枚举类型的定义中,包含枚举值5的是
随机试题
Wemaylookattheworldaroundus,butsomehowwemanagenottoseeituntilwhateverwe’vebecomeusedtosuddenlydisappears.
功用温中朴虚,和里缓急的方剂是
高度在20m处的作业属于()高处作业。
登记账簿时,发生的空行要用斜线注销,发生的空页则可以撕掉。()
审计计划由( )组成。
《浙江省旅游管理条例》规定,发展旅游业应当坚持社会主义物质文明和精神文明建设并重,()的原则。
下列气候类型中,降水集中在冬季的是()。
A、36B、72C、48D、70D(6+2)×7×2=112,(5+2)×3×2=42,(4+3)×5×2=(70)。
(1993年)设数量场则div(gradu)=_____________.
A、Itisconfinedbytimeandspace.B、Itcanincreaseeducationalopportunitieswithoutincreasedbudgets.C、Itmakesupforthe
最新回复
(
0
)