首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
使用VC6打开考生文件夹下的工程test19_1,此工程包含一个源程序文件test19_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下: 1: weight:5 age:0 2: weight:7
使用VC6打开考生文件夹下的工程test19_1,此工程包含一个源程序文件test19_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下: 1: weight:5 age:0 2: weight:7
admin
2009-01-15
84
问题
使用VC6打开考生文件夹下的工程test19_1,此工程包含一个源程序文件test19_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下:
1:
weight:5
age:0
2:
weight:7
age:9
源程序文件test19_1.cpp 清单如下:
#include <iostream.h>
class animal
{
public:
/**************** found *******************/
friend void setvalue(animal&,int);
/**************** found *******************/
void print()
protected:
int itsweight;
int itsage;
};
void animal::print()
{
cout<<"weight:"<<itsweight<<end1;
cout<<"age:"<<itsage<<end1;
}
void setvalue(animal &ta,int tw)
{
ta.itsweight=tw;
ta.ihsage=0;
}
void setvalue(animal &ta,int tw, int tn)
{
ta.itsweight=tw;
ta.itsage=tn;
}
void main()
{
/**************** found *******************/
animal peppy
setvalue(peppy,5);
cout<<"1:"<<end1;
peppy.print();
setvalue(peppy,7,9);
cout<<"2:"<<end1;
peppy.print();
}
选项
答案
(1)错误:缺少友元函数的声明 正确:添加友元函数的声明friend void setvalue(animal &,int,int); (2)错误:viod print(); 正确:void print(); (3)错误:animal peppy 正确:animal peppy;
解析
(1)主要考查考生对于成员函数定义规则的掌握,成员函数必须先声明再使用,即使是友元函数也不例外;
(2)主要考查考生对于关键字的掌握,空类型的关键字应用"void";
(3)主要考查考生对于变量定义的掌握,该处缺少“;”。
转载请注明原文地址:https://kaotiyun.com/show/UOID777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
医生诊疗费用的低下与药品加成的过高,共同形成了以药养医的现状。它保证了公共医院在数据上的收支平衡,却导致了“大处方”“新特贵药”“过度医疗”等现象的出现,让医生和患者都容易成为扭结的医疗制度及以其为轴的社会冲突的代偿者。2016年,患者魏则西的去世和医生陈
_______。喝茶能加速体内酒精的分解,且其利尿作用可帮助分解后的物质排出,因此有助于解酒;但同时,这种加速分解会增加肝肾的负担。因此,对于肝肾不好的人来说,最好不要用茶来解酒,特别要注意的是不能在酒后喝浓茶。填入画横线部分最恰当的一句是(
裸眼3D指的是眼睛不需要佩戴眼镜或者头盔等任何辅助设备,就可以看到3D图像,包括借助显示屏实现三维成像和在三维空间直接成像两种技术。关于裸眼3D相关技术,下列说法错误的是()。
简述苏共二十大的主要内容与影响。(东北师范大学2002年世界现代史真题)
计算两次考试成绩(X、Y)的相关系数。
设X~N(0,σ2),则服从自由度为n-1的t分布的随机变量是()
初学电脑打字时,练习次数越多,错误就会越少,这属于()
已知某次学业成就测验的平均分数是80,标准差为4。如果某考生得分为92,则该分数转换为标准分后是()
教育的社会发展功能不是教育自身的功能。
只有在部分准备金制度下,才可能有存款货币的创造。()
随机试题
下列各项中,某行业()的出现一般表明该行业进入了衰退期。Ⅰ.产品价格不断下降Ⅱ.公司经营风险加大Ⅲ.公司的利润减少并出现亏损Ⅳ.公司数量不断减少
病毒感染的炎症病变中,以()渗出为主。
粉体喷射搅拌桩施工的要求有()。
委托手续费是投资者在办理委托买卖时,向()缴纳的手续费。
课堂导入方式多种多样。教师在上课时,运用学生在生活中熟悉或关心的事例导入新课,能使学生产生一种亲切感,也可以介绍新颖醒目的事例,为学生创设引人入胜、新奇的学习情境。
继“微博”之后,“微信”逐渐成为政府与群众沟通交流的新平台,人们亲切地称之为“指尖上的政民对话”。政务微信的开通()。
某矿山发生了一起严重的安全事故。关于事故原因,甲、乙、丙、丁四位负责人有如下断定:甲:如果造成事故的直接原因是设备故障,那么肯定有人违反操作规程。乙:确实有人违反操作规程,但造成事故的直接原因不是设备故障。丙:造成事故的直接原因确实是设备故障,但并没有人违
圆(x-1)2+(y-1)2=4上到直线x+y-2=0的距离等于2的点的个数为().
Supposeyourgraduationthesisisawardedasanexcellentone,writeanemailtoyourthesissupervisortoexpressyourapprecia
在考生文件夹下创建一个下拉式菜单mymenu.mnx,并生成菜单程序mymenu.mpr。运行该菜单程序时会在当前VisualFoxPro系统菜单的末尾追加一个“考试”子菜单,包括“计算和考试”两条菜单,如下图所示。“计算”和“返回”菜单命令
最新回复
(
0
)