首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面程序的执行结果是( )。 #include<iostream> using namespace std; class building { public: building() {} build
下面程序的执行结果是( )。 #include<iostream> using namespace std; class building { public: building() {} build
admin
2009-01-15
73
问题
下面程序的执行结果是( )。 #include<iostream> using namespace std; class building { public: building() {} building(unsigned stories, float breadths, float lengths) { story = stories; breadth = breadths; length = lengths;} void getstory(void) { cout<<"story is:"<<story<<endl;} void getarea(void) { area = length*breadth*story;cout<<"area is:"<<area<<endl;} private: unsigned story; float length; float breadth; float area; }; void main(void) { building b1,b2;building b3(10u,16.6,58.8); b1.getstory(); b1.getarea(); b2.getstory(); b2.getarea(); b3.getstory(); b3.getarea();}
选项
A、story is:0 area is:0 story is:0 area is:0 story is:10 area is:9760.8
B、story is:null area is:null story is:null area is:null story is:10 area is:9760.8
C、前两个对象输出的结果是不定的,后一个对象的结果正确
D、前两个对象没有初值,因此程序编译时出错
答案
4
解析
该题是关于构造函数重载的,由于前两个对象没有赋初值,值不定。
转载请注明原文地址:https://kaotiyun.com/show/50kp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下面关于位运算符的叙述,正确的是
在关系数据库中,用来表示实体问联系的是
在一个C源程序文件中所定义的全局变量,其作用域为()。
若有函数首部intfun(doublex[10],int,*n),则下列针对此函数的函数声明语句中正确的是()。
若有定义:inta,b;通过语句scanf("%d;%d",&a,&b);能把整数3赋给变量a,5赋给变量b的输入数据是
设有下面的定义:structst{inta;floatb;}d;int*p;要使p指向结构变量d中的a成员,正确的赋值语句是()。
设voidfun(intn,char*s){……},则下面对函数指针的定义和赋值均正确的是()。
结构化程序由顺序、选择、循环三种基本结构组成,以下相关叙述错误的是
下列选项中属于面向对象设计方法主要特征的是()。
在算法的5个特性中,算法必须能在执行有限个步骤之后终止,指的是算法的【】性。
随机试题
我国《草原法》中规定的基本草原的范围包括()
胸膜下界的体表投影在肩胛下线相交于()
男,26岁,5天来鼻及牙龈出血,皮肤瘀斑。血红蛋白55g/L,白细胞10.0×109/L.血小板16×109/L。骨髓增生极度活跃,绝大多数细胞里清一色,胞浆内有大小不等颗粒及成堆Auer小体,过氧化酶染色强阳性。应首选的治疗
甲企业因基建需要竹签,与乙厂签订了一供货合同。合同约定乙供应甲竹签100捆,每根竹签单价1元,未约定总价。乙如约按惯例供应竹签100捆,每捆。100根,甲企业以自己认为每捆竹签为10根,现每捆竹签为100根为由,主张变更合同,遭乙企业反对,双方发生纠纷。对
某投资人投资303万元认购某开放式基金,认购金额在募集期间产生的利息为300元,其对应的认购费率为1%,基金份额面值为1元,则其认购费用和认购份额分别为()。
证券经营机构有下列()情形之一的,不得注册登记为保荐机构。
车船税的纳税义务发生时间,为购买车船发票记载日期的当月。()
浮世绘是日本传统的一种版画形式,代表人物有()。
A2-B2=(A+B)(A-B)的充分必要条件是________.
Myelderbrotherissimilarintemper______myfatherallthetime.
最新回复
(
0
)