首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include<iostream> using namespace std; class sample { private: intx,y; public: smnple(in
有如下程序: #include<iostream> using namespace std; class sample { private: intx,y; public: smnple(in
admin
2018-10-21
53
问题
有如下程序:
#include<iostream>
using namespace std;
class sample
{
private:
intx,y;
public:
smnple(int i,int j)
{
x=i:
y=j;
}
void disp()
{
cout<<’’disp1’’<<end1;
}
void disp()const
{
cout<<’’disp2’’<<end1;
}
};
int main()
{
const sample a(1,2);
a.disp();
return 0;
}
该程序运行后的输出结果是( )。
选项
A、disp1
B、disp2
C、disp1 disp2
D、程序编译时出错
答案
B
解析
因为对象a被定义为常对象,所以a.disp()语句调用的是类的常成员函数voiddisp()const,输出的结果是disp2。
转载请注明原文地址:https://kaotiyun.com/show/X5Ap777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
相对于数据库系统,文件系统的主要缺陷有数据关联性差、数据不一致性和
设px是指向一个类动态对象的指针变量,则执行"deletepx;"语句时,将自动调用该类的______。
已知语句intm=10;则下列引用的表示中正确的是
有以下程序:#include<iostream>usingnamespacestd;intmain(){intx=15;while(x>10&&x<50){x+
两个或两个以上模块之间关联的紧密程度称为()。
已知下列程序的输出结果是42,请将横线处缺失的部分补充完整。#include<iostream>usingnamespacestd;classFoo{intvalue;p
有下列程序:#include<iostream>usingnamespacestd;classTestClass1{public:TestClass1(){cout<<"A";}
关系模型允许定义3类数据约束,下列不属于数据约束的是
生产每种产品需要多种零件,则实体产品和零件间的联系是
随机试题
中贵人将骑数十纵,见匈奴三人,与战。三人还射,伤中贵人,杀其骑且尽。中贵人走广。广曰:“是必射雕者也。”广乃遂从百骑往驰三人。三人亡马步行,行数十里。广令其骑张左右翼,而广身自射彼三人者,杀其二人,生得一人,果匈奴射雕者也。已缚之,上马,望匈奴有数千骑,见
We’vetestedthreehundredtypesofboots,______iscompletelywaterproof.
巴豆内服最为适宜的剂型是
育龄妇女IDA发病率为
本我遵循的是()。
以下关于局部变量的叙述中错误的是
•Readthearticlebelowaboutaplanttour.•Inmostofthelines41-52thereisoneextraword.Itiseithergrammaticallyinco
Thehealth-careeconomyisrepletewithunusualandevenuniqueeconomicrelationships.Oneoftheleastunderstanding【S1】______
Itisallverywelltoblametrafficjams,thecostofpetrolandthequickpaceofmodernlife,butmannersontheroadsarebec
A、Thewomanwantstofindajob.B、Thewomanneedssomeinformation.C、Themangetswhathewants.D、Themanlikesgamblingwith
最新回复
(
0
)