首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class sample { private: intx,y; public: sample(int i,int j)
有如下程序: #include using namespace std; class sample { private: intx,y; public: sample(int i,int j)
admin
2012-12-29
50
问题
有如下程序:
#include
using namespace std;
class sample
{
private:
intx,y;
public:
sample(int i,int j)
{
x=i:
y=j;
}
void disp()
{
cout<<“disp 1”<
}
void dispoconst
{
cout<<”disp2”<
}
};
int main()
{
const sample a(1,2);
a.disp();
return0;
}
该程序运行后的输出结果是( )。
选项
A、disp1
B、disp2
C、disp1 disp2
D、程序编译时出错
答案
B
解析
因为对象a被定义为常对象,所以a.disp()语句调用的是类的常成员函数void disp()const,输出的结果是disp2。
转载请注明原文地址:https://kaotiyun.com/show/ZMVp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有二叉树如下图所示: 则前序序列为()。
以下选项中不合法的标识符是()。
若有如下函数定义 doublefun(intx,inty) {return(x+y);} return语句中表达式值的类型与说明的类型不一致,则以下叙述中正确的是()。
若有如下形式的函数 intfun(inta[],int*p,intn) {……} 调用函数之前需要对函数进行声明,则以下选项中错误的是()。
有以下程序: #include<stdio.h> main() { chars[]={"012xy"}; inti,n=0; for(i=0;s[i]!=0;i++) if(s[i]>=’a’&&s[i]<=’z’)
有以下程序 #include<stdio.h> #include<math.h> main() { ints;floatn,t,pai; t=1,pai=0,n=1.0,s=1; while(fabs(t)>1.0e-6)
有如下程序 #include<stdio.h> main() { chara=’0’,b=’A’; inti; for(i=1;i<6;i++) { if(i%2==0)putchar(a+i);
对于以下函数声明 voidfun(intarray[4],int*ptr);以下叙述中正确的是()。
下列各序列中不是堆的是()。
随机试题
A.中央前回B.第一和第二感觉区C.皮层联络D.扣带回人类快痛的主要投射皮层是
患者,女性,26岁。已婚,停经46天,下腹部轻度阵发性疼痛及阴道少量流血,伴血块10小时。妇科检查示:子宫稍大,宫口未开。对于该患者来说,最有效的紧急止血措施是
患者,女,26岁。被人发现时躺在公园一角落呈半昏迷状态。查体:神志不清,两瞳孔针尖样大小,口角流涎,口唇紫绀,两肺满布水泡音,心率60次/分。肌肉有震颤。应首先考虑的是()
若流动比率大于1,则下列结论中,不一定成立的有()。
我国最早的春联“新年纳余庆,佳节号长春”的作者是()。
职业道德的遵守与提高社会整体道德水平无关。()
刑事案件的立案包括对立案材料的接受,对立案材料的审查和立案的审批。()
MostforecastssuggestthatBritainwillbeapoorercountryafterBrexit,largelybecausetradingwiththeEuropeanUnionwill
Thoughsomepeoplehavesuggestedthatwomenshouldreturntohouseworkinordertoleavemorejobsformen,theideahasbeenr
Manypeoplewonderwhysomemenwanttoliveonthemoon.Itis【1】notthekindofplacewheremostmenwouldchoosetolive.But
最新回复
(
0
)