首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include #include using namespace std; class XCD{ char*a: int b; public:
有如下程序: #include #include using namespace std; class XCD{ char*a: int b; public:
admin
2020-11-11
17
问题
有如下程序:
#include
#include
using namespace std;
class XCD{
char*a:
int b;
public:
XCD(char*aa,int bb){
a-new char[strlen(aa)+1];
strcpy(a,aa);
b=bb;
}
char*Geta(){return a;}
int Getb(){return b;}
};
int main(){
char*p1=ˊˊabedˊˊ,*p2=ˊˊweirongˊˊ;
int d1=6,d2=8;
XCD x(p1,d1),y(p2,d2);
cout<
return 0;
}
运行时的输出结果是( )。
选项
A、12
B、16
C、14
D、11
答案
A
解析
由类XCD的定义可知,成员函数Geta()返回的是字符串的长度,Getb()返回的是参数b的值。在主函数中 strlen(x.Geta())的值等于4,y.Getb()的值等于8,所以输出两者的和为12。
转载请注明原文地址:https://kaotiyun.com/show/WMyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
以下程序的输出的结果是()。#includeintx=3;voidmain(){voidfun();inti;for(i=1;i
在进行任何C++流的操作后,都可以用C抖流的有关成员函数检测流的状态;其中只能用于检测输入流状态的操作函数名称是()。
使用VC6打开考生文件夹下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使程序正常运行,并使程序输出的结果为:Maxis7提示:max()函数实现找出两个数中的最大值,并作为函数值返回。注意:错误的语
使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,补充空出的代码。sum(intn)计算所有n的因子之和(不包括1和自身)。注意:不能修改程序的其他部分,只能补充sum()函数。#inCludeintsum(
使用VC6打开考生文件夹下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为:Number=7Number=12注意:错误的语句在//******error******的下面,修改该语句
使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。(1)定义私有数据成员year、month、day,分别用于年、月、日,它们都是int型的数据,请在注释//********1
下面不属于C++的预定义的流对象是()。
软件调试的目的是()。
运算符重载时不需要保持的性质是()。
设树T的深度为4,其中度为1,2,3,4的结点个数分别为4,2,1,1。则T中的叶子结点数为()。
随机试题
癫痫失神发作应首选下列哪种抗癫痫药物治疗
黯然魂销对于()相当于()对于疲劳
呕血住院患者,最支持门脉高压的依据是
禁忌与铁剂同服的是()
合同法的基本原则包括( )。
损益类账户一般无期末余额。()
在基本经济进货批量模式中,经济进货批量的确定与存货的买价无关。()
反腐败如何坚持标本兼治、综合治理、惩防并举、注重预防的方针。
将10名运动员平均分成两组进行对抗赛,问有多少种不同的分法?()
阅读以下说明,回答问题1~问题2,将解答填入答题纸对应的解答栏内。(2008年5月下午试题三)【说明】Linux是一个类UNIX的操作系统,其功能强大,适合构建网络服务平台,提供DNS、WWW、FIT、NAT等服务。在安装Linux
最新回复
(
0
)