首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
使用VC6打开考生文件夹下的源程序文件modi3.cpp,其中定义了用于表示矩形的CRect类,但类CRect的定义并不完整。请按要求完成下列操作,将类CRect的定义补充完成。 (1)定义私有数据成员leftPoint、topPoint、rightP
使用VC6打开考生文件夹下的源程序文件modi3.cpp,其中定义了用于表示矩形的CRect类,但类CRect的定义并不完整。请按要求完成下列操作,将类CRect的定义补充完成。 (1)定义私有数据成员leftPoint、topPoint、rightP
admin
2017-09-20
19
问题
使用VC6打开考生文件夹下的源程序文件modi3.cpp,其中定义了用于表示矩形的CRect类,但类CRect的定义并不完整。请按要求完成下列操作,将类CRect的定义补充完成。
(1)定义私有数据成员leftPoint、topPoint、rightPoint、bottomPoint,分别用于表示矩形左上角及右下角的点的坐标,它们都是double型的数据。请在注释∥********1********之后添加适当的语句。
(2)完成默认构造函数CRect的定义,指定缺省实参为0,都是double型的数据。请在注释∥********2********之后添加适当的语句。
(3)定义函数体为空的析构函数。请在注释∥********3********之后添加适当的语句。
(4)在main()函数中定义CRect类的实例rect2,并把rect1 的值赋给rect2。 请在注释∥********4********之后添加适当的语句。
注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。
#include
Class CRect
{
private:
∥********1********
public:
∥********2********
∥********3********
void SetPoints(double,
double,double,double);
void SetLeftPoint(double m){leftPoint=m;)
void SetRightP0int(double m){ rightPoint=m;)
void SetTopPoint(double m){topPoint=m;)
void SetBottomPoint(double m){bottomPoint=m;)
void Di splay();
};
CRect::CRect(double 1,double
t,double r,double b)
{
leftPoint=1;topPoint=t;
rightPoint=r;bottomPoint
=b;
}
void CRect::SetPoints(double
1,double t,double r,double b)
{
leftPoint=1;topPoint=t;
rightPoint=r;bottomPoint
=b;
}
void CRect::misplay()
{
cout<<“left—top point iS
(”<<1eftPoint<<“,”<
cout<<”right—bottom point is
(”<
nt<<¨)¨<<’\n’;
}
void msin(){
CReCt rect0;
rect0.Di splay();
rect0.SetPointS(20,20.6,30,4 0);
rect0.Display();
CRect rectl(0,0,150,150);
rectl.SetTopP0int(10.5);
rectl.SetLeftPoint(10.5);
∥********4********
rect2.Di splay();
}
选项
答案
(1)添加语句:double leftPoint,topPoint,rightPoint,bottomPoint; (2)添加语句:CRect(double leftPoint=0,double topPoint=0,double rightPoint=0,double bottomPoint=0); (3)添加语句:~CRect(){); (4)添加语句:CRect rect2(rectl);
解析
程序中定义了一个表示矩形的类CRect,该类中定义了私有数据成员leftPoint、topPoint、rightPoint、bottomPoint,分别用于表示矩形左上角及右下角的点的坐标且它们的数据类型都是double型,类CRect有多个成员函数,SetPoints(),SetLefiPoint0函数可改变成员变量leftPoint的值,而SetRightPoint()成员函数可改变rightPoint的值,SetTopPoint0可改变topPoint的值,SetBottomPoint()改变bottomPoint的值,Display()成员函数显示成员变量的值。
转载请注明原文地址:https://kaotiyun.com/show/5TAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
C++本身没有定义I/O操作,但I/O操作包含在C++实现中。C++标准库iostream提供了基本的I/O类。I/O操作分别由类istream和()提供。
下面程序执行的结果是【 】。#include<iostream>usingnamespacestd;voidmain(){intsum=0;intarray[6]={1,2,3,4,5,6
以下程序的输出结果为main()int m=7,n=4;float a=38.4,b=6.4,x;x=m/2+n*a/b+1/2;cout<<x<<end1;}
若有以下定义和语句 int a=4,b=3,*p, *q, *w; p=&a; q=&b; w=q; q=NULL; 则以下选项中错误的语句是
下列叙述中正确的是
C++定义了类库实现数据的输入和输出,______为根基类。
下列对字符数组进行初始化的语句正确的是
在一个容量为24的循环队列中,若头指针front=8,尾指针rear=3,则该循环队列中共有______个元素。
定义在类内部的函数被类默认为【】,在类外部每次调用该函数时,定义的函数代码会在调用函数位置展开。
随机试题
夫妇甲乙生有两子一女,早年购置房屋5间。2017年甲乙立下遗嘱将东边两间房分给大儿子,西边两间房分给小儿子,北房一间房分给女儿。2018年8月甲与大儿子发生矛盾,甲乙即到公证处作出公证遗嘱将东房一间分给女儿继承,另一间东房仍归大儿子继承,西房两间分给小儿子
国际金融危机中的RZT股份有限公司三年前,一些G20成员国进入了经济衰退期,国际金融危机爆发。虽然去年年底出现了一些经济复苏信号,但现在看来仍不乐观。为了防止国际货币市场产生新的危机,G20国家的财政部部长在日内瓦召开了第四次会议。经济低迷的影响在全球
患者。女,31岁。神疲乏力。少气懒言,形体消瘦,劳累则月经漏下不止,舌质淡白,脉弱。其证候是
合伙人甲因个人炒股,欠债15万元。鉴于甲在普通合伙企业中有价值15万元的财产份额,所以甲的债权人提出如下几种解决方案,其中符合法律规定的有()。
电话心理咨询最适合于()。
行政监察机关和审计机关拥有()。
小明在做算术题时,老师告诉他“285.47+13.88”这道题中的一个小数点点错了化置,结果也错了,偏小100多,小明仔细看过后,纠正了答案,正确答案是多少?
说明运动训练手段的基本分类。
简述中国古代法典从《唐律疏议》到《大清律例》篇章体例的发展演变。
在图7-3所示的DOS命令窗口中,所运行的Windows命令是(1)。A.ipconfig/renewB.tracertwww.rkb.gov.cnC.nslookupwww.rkb.gov.cnD.rou
最新回复
(
0
)