首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #inc1ude<iostream> #inc1ude<cstring>. using namespace std; class XCD{ char*a: int b: public:
有如下程序: #inc1ude<iostream> #inc1ude<cstring>. using namespace std; class XCD{ char*a: int b: public:
admin
2019-06-12
25
问题
有如下程序:
#inc1ude<iostream>
#inc1ude<cstring>.
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="abcd",*p2="weirong";
int d1=6,d2=8;
XCD x(p1, d1), y(p2, d2);
cout<<strlen(x.Geta())+y.Getb()<<end1;
return0;
}
运行时的输出结果是( )。
选项
A、12
B、16
C、14
D、11
答案
A
解析
由类XCD的定义可知,成员函数Geta()返回的是字符串的长度,Getb0返回的是参数b的值。在主函数中strlen(x.Geta(》的值等于4,y.Getb()的值等于8,所以输出两者的和为12。
转载请注明原文地址:https://kaotiyun.com/show/OU8p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
C++中将两个字符串连接起来组成一个字符串的函数是__________。
当循环队列非空且队尾指针等于队头指针时,说明循环队列已满,不能进行入队运算。这种情况称为()。
以下叙述正确的是
面向对象程序设计思想的主要特征中不包括
下列字符串中,正确的C++标识符是()。
每个以符号________开头的行,为编译预处理行。
下列程序是一个函数模板,用于把数组a的每个元素按照逆序放入数组b中。请填空完成该函数模板的定义template<classType>voidFunc(Typea[],Typeb[],【 】){for(in
下列有关继承和派生的叙述中,正确的是A)派生类不能访问基类的保护成员B)作为虚基类的类不能被实例化C)派生类应当向基类的构造函数传递参数D)虚函数必须在派生类中重新实现
派生类继承基类的方式有
在C++中,打开一个文件,就是将这个文件与一个()建立关联,关闭一个文件,就是取消这种关联。
随机试题
什么是不锈钢的应力腐蚀?如何防止应力腐蚀?
下列对划线支票说法错误的是()
为降低颅内压而进行的处理不包括
A.最易导致肠管损伤B.易引起迷走神经综合征C.易引起颈管粘连D.易引起DICE.易引起失血性休克稽留流产
一般情况,选择性催化还原法比非选择性催化还原法的排烟脱氮处理成本()。
根据《统计法实施细则》规定,国家建立健全统计数据质量监控和评估的制度,加强对各省、自治区、直辖市国内生产总值等重要统计数据的监控和评估。( )
某民营企业经过十多年努力,逐步发展成为一个具有相当经营规模和较高知名度的上市公司。但在最近,公司发展却陷入了困境。经过冷静分析,公司董事会认为,这种困境不是经营环境的变化导致的,而是家族制和落后的管理造成的。因此,公司董事会决定,向社会公开招聘总经理,对落
培训需求分析就是采用科学的方法。弄清()。
银行的实质是()。
QualityAssuranceatAllStagesWerecognizethatthekeytoqualityassuranceiscontinuousalertness.Thatiswhyoursyst
最新回复
(
0
)