首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
48
问题
有如下程序:
#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全国计算机二级
相关试题推荐
有如下类定义:classTest{public:Test(){a=0;c=0;} //①intf(inta)const{this->a=a;} //②staticint
有如下程序:#includeusingnamespacestd;classSample{friendlongfun(Samples);public:Sample(longa){x=a;}private:long
下列关于函数模板的表述中,正确的是
有如下程序:#include#includeusingstd::cout;classPoint{public:frienddoubledi
有如下程序:#includeusingnamespacestd;voidf1(int&x,int&y){intz=x+y;x=y;y=z;}voidf2(intx,i
Windows环境下,由C++源程序文件编译而成的目标文件的扩展名是
有如下类声明:classHow{intk;public:~How(){cout
除了显式定义的构造函数外,类中还有可能包含编译器自动生成的构造函数,因此一个类所拥有的构造函数的至少有
有如下头文件:intf1();staticintf2();classMA{public:intf3();staticintf4();};在所描述的函数中,具有隐含的this指针的是()。
常量4.2,4.2f,4L的数据类型分别是
随机试题
阅读下面语段,回答问题:【端正好】碧云天,黄花地,西风紧,北雁南飞。晓来谁染霜林醉?总是离人泪。【滚绣球】恨相见得迟,怨归去得疾。柳丝长玉骢难系,恨不得倩疏林挂住斜晖。马儿迍迍的行,车儿快快的随,却告了相思回避,破题儿又早别离。听得道一
微丸剂的制备方法常用如下哪种方法
下列关于抽样误差的论述错误的是
广义的城市市政公用设施分为()两大类。
最常见的利率违规行为是()。
百里油菜花海所在地,且是北方小油菜发源地的是下列的()。
学生是人,是教育的对象,因而他们()。
Musiccomesinmanyforms;mostcountrieshaveastyleoftheirown【C1】______theturnofthecenturywhenjazzwasborn,America
A.printedB.somewhatC.sourceD.gatherE.competitionF.failsG.purposeH.influenceI.originJ.spreadK.innova
A、Naturaldisasters.B、Largechemicalfactories.C、Exhaustfromvehicles.D、Largeamountsofhouseholdgarbage.B男士说汽车尾气给环境造成很大的
最新回复
(
0
)