首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2。本程序中有两个类:一是时间类(Time),用于表示一天中的时间,采用24小时制;另一个是街灯类(StreetLight),用于表示街上的路灯。StreetLight类中有Time类的
请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2。本程序中有两个类:一是时间类(Time),用于表示一天中的时间,采用24小时制;另一个是街灯类(StreetLight),用于表示街上的路灯。StreetLight类中有Time类的
admin
2015-06-27
42
问题
请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2。本程序中有两个类:一是时间类(Time),用于表示一天中的时间,采用24小时制;另一个是街灯类(StreetLight),用于表示街上的路灯。StreetLight类中有Time类的数据成员。这里对StreetLight类的数据成员和成员函数做一下说明:
intid;//街灯的id
boolison;//街灯的状态,true表示街灯已经开启,false表示街灯关闭
Timecurrenttime;//当前时间
voidturnon();//打开街灯
voidturnoff();//关闭街灯
boolcheck(Timetimethreshold);//判断是否过了可开灯的时间,并需要
//开灯
//(time_threshold)
请在程序中//**********found**********之下一行的横线处填写适当的代码,并删除横线,使程序完整、正确。
输出结果为:
TurnonLight2
给定源程序
#include
usingnamespacestd;
classTime{
private:
inthour;
intminute;
intsecond;
public:
Time(inth,intm,ints){
this->hour=h;
this->minute=m;
thiS->second=s;
}
booloperator>(Time&right)
const{
if(this->hour>right.hour||
(this->hour==right.
hour&&this->minute>right.minute)||
(this->hour==right.hour
&&this->minute==right.minute&&
this->second>right.second))
//**********found**********
________;
returnfalse;
}
};
classStreetLight{
private:
intid;
boolison;
Timecurrenttime;
public:
StreetLight(intid,inthour,intminute,intsecond)
//**********found**********
:________
{
this->ison=false;
this->id=id;
}
voidturnon(){
this->ison=true;
cout<<"TurnonLight"<
id<
}
voidturnoff(){
//**********found**********
}
boolcheck(Timetimethreshold){
if(this->ison)
returnfalse;
if(currenttime>time
threshold)
returntrue;
//**********found**********
return________;
}
};
intmain(){
StreetLight*lightl=newStreetLight
(1,17,34,45);
StreetLight*light2=newStreetLight
(2,18,34,45);
Timetimethreshold(18,0,0);
if(1ightl->check(time—threshold))
lightl->turn_on();
if(1ight2->check(time_threshold))
light2->turn—on();
return0;
}
选项
答案
(1)returntrue; (2)current_time(hour,minute,second) (3)this->is_on=false; (4)false;
解析
(1)主要考查考生对重载操作符的掌握情况,根据需要重载‘>’操作符的含义,当前时间大于开灯时间,返回true。
(2)主要考查考生对构造函数的掌握,StreetLight类在构造函数的成员初始化列表中完成对成员对象current_time的初始化。
(3)主要考查考生对成员函数的掌握,由该函数的功能可知,该函数功能是将灯关闭,设置is_on为false。
(4)主要考查考生对成员函数的掌握,由该函数的功能可知,当灯在关闭的前提下,若当前时间过了开灯时间,则返回true,以此条件判断开灯;其他条件下灯都处于关闭状态,返回false。
转载请注明原文地址:https://jikaoti.com/ti/ukXiFFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列方法中,可以用来测量持续性注意的是
在随机区组实验设计中,总平方和可以被分解为()
次数分布有两个基本特点,分别是()
假设职工用于上下班路途的时间服从正态分布,经抽样调查得知这一时间为1.2小时。调查人员根据以往的调查经验,认为这一时间与往年没有多大变化。为了证实这一看法,需要采取的假设检验方法是()
设一个盒子里装有编号为①②③的三个球,现按照考虑顺序的重复抽样方式从中随机抽出两个球组成样本,则样本可能数目为()
某市政府建新办公大楼,工程由某建筑公司承包。工程按期竣工并验收合格后,市政府由于财政困难,部分工程款一直未按期付给建筑公司,致该公司陷入严重经济困难。建筑公司认为自己的合法权益被侵犯,遂诉至法院。本案中,市政府应负()。
在我国,诉讼程序法包括()。
清朝乾隆年间,四川重庆府某甲“因戏而误杀旁人”,被判处绞监候。依据清代的会审制度,对某甲戏杀案的处理,适用的程序是
以下选项中不属于我国法律制定程序的是()
有下列二叉树,对此二叉树进行后序遍历的结果为()。
随机试题
茶叶灼烧后灰分中留下的氧化物以何种成分较多?其含量有多少?
芍药汤的功效是
A.无环鸟苷B.灰黄霉素C.扑尔敏D.强的松E.红霉素治疗湿疹的口服药物
1988年巴塞尔报告的主要内容是()。
已知φ(1.282)=0.9,则φ(-1.282)为()。
依据《旅行社投保旅行社责任保险规定》,下列属于旅行社除外责任的是()。
现代人力资源管理的内容应()。(2007年11月三级真题)
求函数u=在约束条件下的最大值与最小值.
Itshouldnotbeasurprise.Lonelinessandsocialisolationareontherise,【C1】______manytocallitanepidemic.Inrecentde
Facebookdevelopedwhatitcallsafoundational"breakthrough":softwarethatenablesmachinestolearntowalkliketoddler
最新回复
(
0
)