首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面程序的执行结果是( )。 #include<iostream> using namespace std; class building { public: building() {} build
下面程序的执行结果是( )。 #include<iostream> using namespace std; class building { public: building() {} build
admin
2009-01-15
84
问题
下面程序的执行结果是( )。 #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://www.kaotiyun.com/show/50kp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有以下程序#include<stdio-h>#include<string.h>typedefstruct{charname[9];charsex;intscore[2];)STU;STUf(STUa){STUb={"Zhao",’
若有定义语句:inta[3][6];,按在内存中的存放顺序,a数组的第10个元素是
有以下程序#include<stdio.h>inta=1,b=2;voidfun1(inta,intb)main(){printf("%d%d",a,b);}{fun1(
以下选项中与if(a==1)a=b;elsea++;语句功能不同的switch语句是
有以下程序#includemain(){inta=0,b=0;/*给a赋值a=10;b=20;给b赋值*/printf("a+b=%d\n",a+b);/*输出计算结果*/}程序运行后的输出结果是
若有定义语句:chars[10]="1234567\0\0";,则str1en(s)的值是
设有定义:charp[]={’1’,’2’,’3’},*q=p;,以下不能计算出一个char型数据所占字节数的表达式是()。
给定程序中,函数fun的功能是将带头结点的单向链表结点数据域中的数据从小到大排序。即若原链表结点数据域从头至尾的数据为:10、4、2、8、6,排序后链表结点数据域从头至尾的数据为:2、4、6、8、10。请在程序的下画线处填入正确的内容并把下画线删
在软件生产过程中,需求信息的来源是()。
随机试题
()油田开发经济评价的主要任务有开展油田开发经济动态预测与分析。
侧柏叶除凉血止血、生发乌发外,又能()。
企业财务比率分析中,反映盈利能力的指标有()。
公司型基金的最高权力机构是()。
下列关于无形资产摊销的表述不正确的有()。
下列项目中,属于借款费用的有()。
如果某人现有退休金100000元,准备存入银行,在银行年复利率为4%的情况下,其10年后可以从银行取得()元。
Ionlyknowthemanby______butIhaveneverspokentohim.
Withtherapiddevelopmentofoureconomy,thepastdecadehaswitnessedaremarkableincreaseinpeople’sincome.Now,moreand
Theabilitytoseewordsoneithersideofthepointatwhichyoureyesfocusiscalledperipheralvision(外围视觉).Foreignstuden
最新回复
(
0
)