首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面程序的执行结果是( )。 #include<iostream> using namespace std; class building { public: building() {} build
下面程序的执行结果是( )。 #include<iostream> using namespace std; class building { public: building() {} build
admin
2009-01-15
76
问题
下面程序的执行结果是( )。 #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全国计算机二级
相关试题推荐
若有以下程序main(){intc;C=1315;printf("%d\n",c);}则程序的输出结果是
下列条件语句中,输出结果与其他语句不同的是
若有定义语句:intx=12,y=8,z;在其后执行语句z=0.9+x/y;则z的值为()。
以下关于结构化程序设计的叙述中正确的是
设有下面的定义:structst{inta;floatb;}d;int*p;要使p指向结构变量d中的a成员,正确的赋值语句是()。
请编写函数fun,其功能是:计算并输出下列多项式的值:例如,在主函数中从键盘给n输入50后,输出为:s=1.718282。注意:要求n的值大于1但不大于100。部分源程序在文件PROGl.C中。请勿改动主函数main
在数据库设计中,将E-R图转换成关系数据模型的过程属于()。
数据流图用于抽象描述一个软件的逻辑模型,数据流图由一些特定的图符构成。下列图符名标识的图符不属于数据流图合法图符的是()。
在数据库设计中,将E-R图转换成关系数据模型的过程属于()。
在数据库设计中,将E-R图转换成关系数据模型的过程属于()。
随机试题
三羧酸循环中脱氢的部位是:()
设A为n阶方阵,Ax=0是非齐次方程组Ax=b的导出组,则下面结论不一定成立的是().
下列对城市规划实施与公共政策之间关系的理解不正确的是()。
工程项目施工进度计划有()。
下列事项中,构成企业费用的是()。
小李收到了一份通知邮件,附件里有一个PDF文件,关于这个文件说法正确的是()。
中国特色社会主义理论体系的精髓是:
设可微函数f(x,y)在点(x0,y0)取得极小值,则下列结论正确的是
Bythe1820’sintheUnitedStates,whensteamboatswerecommononwesternwaters,theseboatsweremostlypoweredbyenginesbu
A、Theshockabusinessmanfeelswhenthereisnoroomforbargaining.B、TheshockPeaceCorpvolunteerssufferedfrominBorneo.
最新回复
(
0
)