首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。 [说明] 下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。 [C++程序] #include <iostream.h> class crop
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。 [说明] 下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。 [C++程序] #include <iostream.h> class crop
admin
2010-12-16
27
问题
阅读以下说明和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
程序员下午应用技术考试
软考初级
相关试题推荐
计算机中的数据是指________________。
在Excel2010中,设A1单元格中的值为20,A2单元格中的值为60,若在C1单元格中输入函数“=AVERAGE(A1,A2)”,按回车键后,,则C1单元格中的值为(
数据分析经常需要把复杂的数据分组,并选取代表,将大量数据压缩或合并得到一个较小的数据集。这个过程称为()。
计算机采用二进制的好处不包括______。
西部某省考试机构工作人员统计了去年下半年三个地区四种资格的报考人数,将统计表抄录如下(其中有一个数据抄错了): 信息处理技术员小王很快就找出了错误的数据,并进行了纠正。错误的数据是(32),该数据应纠正为(33)。33.
在Excel2010的A1单元格中输入函数“=IF(1<>2,1,2)”,按回车键后,A1单元格中的值为________________。
小张刚接到领导分配的数据分析任务,他第一步应当首先________。
在Excel中,A1:C3区域中各单元格的值都为10,如果在D1单元格中输入公式“=SUM(A1,C3)”,则D1单元格中显示的值为(58)。
下面记录的是某班36人期末考试的数学成绩:971009596100879610089100936999891008188
以下定性的分类变量中,(9)属于有序变量(能排序)。
随机试题
全国人大及其常委会加强对立法工作的组织协调,发挥在立法工作中的主导作用。()
A、featB、greatC、teachD、reachB
输血时主要考虑供血者的()
肾病综合征的病理生理改变中意义最大的是
使用血压计袖带过窄,测量的血压数值()
甲与现役军人乙在2000年结婚,婚后因感情不和分居至今,甲于2004年5月向法院提出离婚,法院应当如何处理:
“阳光是最好的消毒剂”,在基金份额的募集过程中,()等募集信息披露文件向公众投资者阐明了基金产品的风险收益特征及有关募集安排,投资者能据以选择适合自己风险偏好和收益预期的基金产品。
企业获得竞争优势的重要因素有()。
目前数据库市场上广泛使用的Oracle是一种()。
AmazonsaiditwillcutpricesonarangeofpopulargoodsasitcompletesitsacquisitionofWholeFoods,sendingsharesofriv
最新回复
(
0
)