首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2。本程序中有两个类:一是时间类(Time),用于表示一天中的时间,采用24小时制;另一个是街灯类(StreetLight),用于表示街上的路灯StreetLight类中有Time类的数
请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2。本程序中有两个类:一是时间类(Time),用于表示一天中的时间,采用24小时制;另一个是街灯类(StreetLight),用于表示街上的路灯StreetLight类中有Time类的数
admin
2015-07-24
61
问题
请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2。本程序中有两个类:一是时间类(Time),用于表示一天中的时间,采用24小时制;另一个是街灯类(StreetLight),用于表示街上的路灯StreetLight类中有Time类的数据成员。这里对StreetLight类的数据成员和成员函数做一下说明:
int id;//街灯的id
bool is_on;//街灯的状态,true表示街灯已经开启,false表示街灯关闭
Time current_time;//当前时间
void turn_on(); //打开街灯
void turn_off(); //关闭街灯
bool check(Time time_threshold);//判断是否过了可开灯的时间,并需要
//开灯
//(time_threshold)
请在程序中//**********found**********之下一行的横线处填写适当的代码,并删除横线,使程序完整、正确。
输出结果为:
Turn on Lisht2
源程序如下:
#include
using namespace std;
class Time{
private:
int hour;
int minute;
int second;
public:
Time(int h,int m,int S){
this->hour=h:
this->minute=m:
this->second=s;
}
bool operator>(Time&fight)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**********
___________;
return false;
}
};
class StreetLight{
private:
int id:
bool is_on;
Time current_time;
public:
StreetLight(int id,int hour,int minute,int second)
//**********found**********
:___________
{
this->is_on=false:
this->id=id:
}
void turn-on(){
this->is_on=true;
cout<<"Turn on Light" <
id<
}
void turn_off(){
//**********found**********
}
bool check(Time time_threshold){
if(this->is_on)
return false;
if(current_time>time_threshold)
return true;
//**********found**********
retum___________;
}
}.
int main(){
StreetLight* lightl=new StreetLight(1,17,34,45);
StreetLight*light2=new StreetLight(2,18,34,45);
Time time_threshold(18,0,0);
if(1ightl->check(time_threshold))
lightl->turn_on();
if(1ight2->check(time_threshold))
light2->turn_on();
return 0;
}
选项
答案
(1)(y—p.y)*(y—p.y); (2)return PI*radius*radius; (3):bottoni.area()*2+bottom.perimeter()*height; (4)return bottom.area()*height:
解析
(1)主要考查考生对成员函数定义的掌握情况,要求返回指定点的距离,根据距离公式,得出调用该成员函数的对象与参数P点之间的距离。
(2)主要考查考生对成员函数定义的掌握,根据圆面积计算公式,给出成员函数area()的定义。
(3)主要考查考生对成员函数定义的掌握,根据圆柱体表面积计算公式,给出成员函数area()的定义。
(4)主要考察考生对成员函数定义的掌握,根据圆柱体体积计算公式,给出成员函数volume()的定义。
转载请注明原文地址:https://kaotiyun.com/show/ucNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
当使用ifstream流类定义一个流对象并打开一个磁盘文件时,文件的隐含打开方式是()。
下面程序的运行结果为#include<iostream.h>classA{staticintn;public:A(){n=1;}A(intnum){n=
有如下的程序:#include<iostream>#include<fstream>usingnamespacestd;intmain(){chars[25]="Programminglanguage";o
()是给对象取一个别名,它引入了对象的同义词。
下面程序的运行结果是#include<iostream.h>classbase{protected:inta;public:base(){cout<<"0";}};
在深度为5的满二叉树中,叶子结点的个数为
在数据库的概念结构设计中,常用的描述工具是【】。
对于常数据成员,下面描述正确的是( )。
用树型结构表示实体类型及实体间联系的数据模型称为【】。
有以下结构体说明和变量的定义,且指针p指向变量a,指针q指向变量b。则不能把结点b连接到结点a之后的语句是structnode{chardata;structnode*next;}a,b,*p=&a,*q=&b
随机试题
下列选项中,可以申请专利的是【】
下列关于个人标准信用信息基础数据库信息采集的说法,错误的是()。
利用账龄分析表可了解下列情况()。
我国横断山脉是具有国际意义生物多样性的关键地区,横亘()。
试述宋代书院制度的产生及其教学特点。
甲和乙、丙依法签订合同,将甲的一套房屋以14万元的价格卖给乙、丙,此合同产生的债属于()。
SchoolLunchResearchhasshownthatoverhalfthechildreninBritainwhotaketheirownlunchestoschooldonoteat【C1】__
Theguidewalkedsofastthatmostofthetouristscouldnot______him.
______forthetimelyinvestmentfromthegeneralpublic,hiscompanywouldnotbesothriving.
E1Ninoisadisturbanceoftheworld’snormalclimatepattern.DuringElNinoevents,thewesterlytradewindsbecomesloweran
最新回复
(
0
)