首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列程序的输出结果是 #include<iostream.h> class Myclass{ public : Myclass( int i=0,int j=0) {x=i;
下列程序的输出结果是 #include<iostream.h> class Myclass{ public : Myclass( int i=0,int j=0) {x=i;
admin
2013-05-30
26
问题
下列程序的输出结果是 #include<iostream.h> class Myclass{ public : Myclass( int i=0,int j=0) {x=i; y=j; } void show( ){cout<<"x="<<x<<" "<"y="<<y<<endl;} void show( )const{cout<<"x="<<" "<<"y="<<y<<endl;} privated: int x; int y; }; void main( ) { Myclass my l (3,4); const my2(7,8); my l.show( );my2.show( );}
选项
A、x=4,y=3;x=7,y=8
B、x=3,y=4;x=7,y=8
C、x=7,y=8;x=4,y=3
D、x=8,y=7;x=7,y=8
答案
1
解析
在Myclass类中定义了两个同名函数show,其中一个是常成员函数。在main函数中定义了两个对象myl,my2,其中对象my2是常对象。这两个对象调用成员函数show时,通过对象myl调用的是没有用const修饰的一般成员函数,而通过对象my2调用的是const修饰的常成员函数。
转载请注明原文地址:https://kaotiyun.com/show/rUNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
对下面的程序,说法正确的是()。#include<iostream>usingnamespacestd;voidsum(floatm,floatn){floatsum=m+n;}main()
磁盘文件操作中,打开文件的访问方式常量中,以追加方式打开文件的是()。
在C++语言中输出“HelloWorld”的语句是()。
下列叙述中错误的是()。
用树型结构表示实体之间联系的模型是______。
()是以一种完全通用的方法来设计函数或类而不必预先说明将被使用的每个对象的类型。
下面不属于软件开发时期的是()。
若某完全二叉树的深度为h,则该完全二叉树中至少有______个结点。
下面关于模板的描述,错误的是
随机试题
正常人紧闭声门而用力呼气时,胸膜腔内压可达
慢性肾功能不全之肾阳衰微证治宜
遗嘱继承
如图5-82所示,ZC是形心轴,ZC轴以下面积对ZC轴的静矩SzC=()。
城市邮政通信枢纽的选址应()。
会计档案由各级()共同负责会计档案工作的指导、监督和检查。
()是指在不同时间内用同一测验(或用另一套相等的测验)重复测量同一被试者,所得结果的一致程度。
以下2题是基于下述描述;设有图书管理数据库:图书(总编号C(6),分类号C(8),书名C(16),作者C(6),出版单位C(20),单价N(6,2))读者(借书证号C(4),单位C(8),姓名C(6),性别C(2),职称C(6),地址C(20))借
Duetolowinvestment,industrialoutputhasremained_______.
A、Toanartisticmuseum.B、Toamovietheater.C、Toarestaurant.D、Toanationalpark.A由选项预测本题可能考查地点。对话一开始女士就说“我要去国家艺术博物馆”,故选A
最新回复
(
0
)