首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
70
问题
有如下程序:
#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全国计算机二级
相关试题推荐
若有如下形式的函数 intfun(inta[],int*p,intn) {……} 调用函数之前需要对函数进行声明,则以下选项中错误的是()。
有以下程序 #include<stdio.h> intadd(inta,intb){return(a+b);} main() {intk,(*f)(),a=5,b=10; f=add; … } 则以下函数调用语句错误的是
若函数调用时的实参为变量,下列关于函数形参和实参的叙述中正确的是()。
有以下程序 #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)
对于以下函数声明 voidfun(intarray[4],int*ptr);以下叙述中正确的是()。
下面选项中不是关系数据库基本特征的是()。
以下选项中不能用作C程序合法常量的是()。
以下选项中不能作为C语言合法常量的是()。
设有定义:doublex=2.12;,以下选项中不能完整输出变量x值的语句是()。
随机试题
1894年11月,日军在中国制造了()
梁某,女性,20岁,间断发热1个月,咳嗽胸痛,咳吐大量脓痰,时有痰血相兼,腥臭异常气喘不能平卧,舌红,苔黄,脉滑数。
紧急避险的情况下,关于行为人所造成的损害限度说法错误的是:
按照融资方式的不同,金融机构可分为()。
(2011年真题)我国出版业主要由()构成。
8,23,27,80,84,251,255,()
人们推出XML主要希望解决的问题是______。
Wheredoesthewomanwork?
A、Thereisanagreementforabantobeacceptedonwhalehunting.B、Peopleinrichcountriesshouldrefusetobuywhaleproduct
______thatshedidn’tdoagoodjob,Idon’tthinkIamablerthanher.
最新回复
(
0
)