首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程pmj1。其中有线段类Line的定义。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应该是: Endpoint1:(1,8),E
请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程pmj1。其中有线段类Line的定义。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应该是: Endpoint1:(1,8),E
admin
2021-02-22
12
问题
请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程pmj1。其中有线段类Line的定义。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应该是:
Endpoint1:(1,8),Endpoint2=(5,2),length=7.2111。
注意:只修改每个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。
#include
#include
usingnamespacestd;
classLine;
doublelength(Line);
classLine{//线段类
doublex1,y1;//线段端点1
doublex2,y2;//线段端点2
public:
//ERROR**********found**********
Line(doublex1,doubley1,double
x2,doubley2)const{
this->x1=x1;
this->y1=y1;
this->x2=x2;
this->y2=y2;
}
doublegetX1()const{returnx1;}
doublegetY1()const{returny1;}
doublegetX2()const{returnx2;}
doublegetY2()const{returny2;}
voidshow()const{
cout《"Endpoint1=("<
cout<<"),Endpoint2=("<
//ERROR**********found**********
cout<<"),length="<
}
};
doublelength(Line1){
//ERROR**********found**********
returnsqrt((1.x1-1.x2)*(1.x1-1.x2)+(1.y1-1.y2)*(1.y1-1.y2));
}
intmain(){
Liner1(1.0,8.0,5.0,2.0);
r1.show();
return0;
}
选项
答案
(1)Line(doublex1,doubley1,doublex2,doubley2){ (2)cout<<"),length="<
解析
(1)主要考查考生对构造函数的掌握,构造函数要给私有成员赋初始值,因此不能使用const来限制。
(2)主要考查考生对this指针的掌握,由函数length的声明doublelength(Line);可知,length函数的形参是Line类,在voidshow()const函数里,this指针指向的是当前:Line类,因此可以用*this表示当前Line类。
(3)主要考查考生对成员函数的掌握,length函数是类外函数,不能直接调用类的私有成员,因此要通过成员函数取得对应的值。
转载请注明原文地址:https://jikaoti.com/ti/nTh0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
定义学生选修课程的关系模式:SC(S#,Sn,C#,Cn,G)(其属性分别为学号、姓名、课程号、课程名、成绩)则该关系的主键为
将数据库的结构划分成多个层次,是为了提高数据库的逻辑独立性和
寸软件系统总体结构图,下面描述中错误的是
下面不属于结构化程序设计原则的是
下面描述中正确的是
在数据管理技术发展的三个阶段中,数据共享最好的是
设二叉树共有500个结点,其中叶子结点有250个。则度为2的结点个数是
有如下程序:#include<iostream>usingnamespacestd;classBoat;classCar{public:Car(inti):weight(i){}
下列结构中为非线性结构的是
随机试题
最可能的诊断是该患者治疗中,下列哪项不恰当
关节腔积液进行理学检查,应采用第几管的标本
两人搬运病人正确的做法是
一幅漫画:××局领导开着空调、电灯;另一幅漫画:××小区居民点着节能灯看报。请谈谈你的看法。
孔子是人不是神。把孔子推上神坛的是后人,并非孔子的过错。在2500年前孔子的思想和成就能达到那样的高度,确实了不起,我们应该充分肯定和尊重,其中今天仍有价值的部分应该很好地珍惜利用。把孔子和儒家学说说得一文不值,是极端和片面的,把孔子作为神来膜拜,把儒学作
简述概念结构的理论。
设二叉树如下:则前序序列为
小李今年毕业后,在一家计算机图书销售公司担任市场部助理,主要的工作职责是为部门经理提供销售信息的分析和汇总。请你根据销售数据报表(“Excel.xlsx”文件),按照如下要求完成统计和分析工作:根据“订单明细表”工作表中的销售数据,统计所有订单的总销
如果进栈序列为A,B,C,D,则可能的出栈序列是
Researchonweb-basedcrosswordsLilaandJakechosethisarticlebecause
最新回复
(
0
)