首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。 [说明] 下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。 [C++程序] #include <iostream.h> class crop
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。 [说明] 下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。 [C++程序] #include <iostream.h> class crop
admin
2010-12-16
62
问题
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。
[说明]
下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。
[C++程序]
#include <iostream.h>
class crop_assessment
{
int actual_crop;
int ideal_crop;
public:
void set(int in_actual,int in_ideal)
{
actual crop=in_actual;
ideal_crop=in_ideal;
}
int get_actual_crop(void){ (1) ;}
int get_ideal_crop(void){ (2) ;)
};
Class lot_size
{
int length;
int width;
(3) crop;
public:
void set(int 1,int w,int a,int i)
{
length=1;
width=w;
crop.set(a,i);
}
int get_area(void){return length*width;}
int get_data(void){return (4) ;}
int get_data2(void)freturn (5) ;}
}
int main()
{
Los_size small,medium;
small.set(5,5,5,25);
medium.set(10,10,10,50);
cout<<"For a small lot of area"<<smallget_area()<<“\n”;
cout<<"the actual crops are$"<<small.get_data2()<<"\n";
cout<<"and ideal crops are$”<<small.get_data()<<"\n";
cout<<"For a medium Lot of area"<<medium.get area()<<:\n”;
cout<<"the actual crops are$"<<medium.get_data2()<<"\n";
cout<<"and ideal crops are$"<<medium.get_data()<<"\n";
return 0;
}
选项
答案
(1) return actual_crop (2) return ideal_crop (3) Crop_assessment (4) crop.get_ideal_crop() (5) crop.get_actual_crop()
解析
本题以C++语言为载体,考查面向对象程序设计中的几个重要概念—类的嵌套及函数的使用。
本题的功能是通过已定义的粮食收成类定义了一个计算特定矩形域上粮食收成的类,在主函数中定义了两个对象,并调用了相应的函数,来输出理想和实际的粮食产量。
首先,由于Crop_assessment定义的成员数据缺省为私有的,所以想要获得实际和理想的粮食产量,要通过两个公有成员函数,所以(1)处应填入“return actual_crop”,(2)处应填入“return ideal_crop”。
其次,在类Lot_size中,由于我们要反映矩形域上的粮食产量,所以我们在类中嵌套定义了一个类,(3)应填入“Crop_assessment”。
最后,由于我们想通过Lot_size类中的getdata和get_data2函数得到粮食产量,但由于这两个成员数据是私有函数,所以我们必须通过定义的对象调用它,所以(4)应填入“crop.get ideal_crop()”,(5)应填入“crop.get actual_crop()”。
转载请注明原文地址:https://kaotiyun.com/show/aBjZ777K
本试题收录于:
程序员下午应用技术考试题库软考初级分类
0
程序员下午应用技术考试
软考初级
相关试题推荐
计算机中的数据是指________________。
信息系统运行过程中的数据备份工作不包括________________。
抽样调查是收集数据的重要方法之一。抽样调查所遵循的原则不包括______。
在Excel2007中,在单元格A1中输入函数“=POWER(2,3)/MAX(1,2,4)”,按回车键后,则A1单元格中的值为__________。
在Word中,下列关于拆分表格的叙述中,正确的是______。
四位二进制数(从0000到1111)中,不含连续三位相同数字的数共有(4)个。
下列关于防火墙的叙述中,不正确的是(17)。
为使双击指定类型的文件名就能调用相应的程序来打开处理它,需要将这种文件类型与相应的程序建立文件(23)。
企业信息化总体架构中,计算机硬件、网络系统、操作系统、数据库管理系统等属于(16)。
下列选项中,不能收发电子邮件的软件是______。
随机试题
外圆磨床床身纵向导轨在垂直平面内的平行度,当最大磨削长度不大于500mm时,公差值为0.2mm/1000mm。()
A.易发生DICB.骨髓无特异性改变C.缺乏葡萄糖脑苷脂酶D.缺乏神经鞘磷酸脂酶E.尿中出现B-J蛋白急性早幼粒细胞性白血病
桑叶具有而菊花不具有的功效是
对于商用房贷款抵押物,以下说法错误的是()。[2010年5月真题]
关于心理社会治疗模式对人的成长发展的假设,下列选项中正确的说法是( )。
在我国各个地区都要实施义务教育,对于法律规定的义务教育的规则,全社会都必须遵守。这体现出义务教育的:
Generallyspeaking,alotofpatienceis______tolookafterasickpatient.
A、Anyastronautreturnsfromtheuniverseissafe.B、Anyastronautreturnsfromtheuniversesuffersalot.C、Wecanassumethat
Itisnevertooearlyforyoutolearnaboutthevalueofmoneyasateenager.Manyteenshaveno【B1】______whatittakestoearn
A、Mostofitislostintheupperandloweratmosphere.B、Mostofitisreflectedbythegasesintheupperatmosphere.C、Mosto
最新回复
(
0
)