首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请使用”答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2,本程序中有两个类:一是日期类(Date),用于表示一天的日期(年、月、日);另一个是截止日期类(Dead-line),用于表示一个任务的截止日期,超过该日期即为超时。Deadline
请使用”答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2,本程序中有两个类:一是日期类(Date),用于表示一天的日期(年、月、日);另一个是截止日期类(Dead-line),用于表示一个任务的截止日期,超过该日期即为超时。Deadline
admin
2020-06-29
24
问题
请使用”答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2,本程序中有两个类:一是日期类(Date),用于表示一天的日期(年、月、日);另一个是截止日期类(Dead-line),用于表示一个任务的截止日期,超过该日期即为超时。Deadline类中有Date类的数据成员。这里对Deadline类的数据成员和成员函数做一下说明:
int id;//截止日期的id
Date end_date;//截止日期,表示允许完成该任务的最后一天
void finish(Date date);//date未超过截止日期时,输出"Finished!t",否则输出"Time out."
bool check(Date date);//date未超过截止日期时返回true,否则返回false。
程序正确情况下输出:
Finished!
Time out.
注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不能删除或移动“//**********found**********”。
1 #include
2 using namespace std;
3 class Date{
4 private:
5 int year;
6 int month;
7 int day of month;
8 public:
9 Date(int y,int m,int d){
10 this->year=y;
11 this->month=m;
12 this->day_of_month=d;
13 }
14 bool operator<=(Date&dt)const{
15 if(this->year
year==dt.year&&this->month
year==dr.year&&this->month==dt.month&&this->day_of_month<=dt.day_of_month))
16 //**********found**********
17 _____;
18 return false;
19 }
20 };
21 class Deadline{
22 private:
23 int id;
24 Date end_date;
25 public:
26 Deadline(int id,int year,int month,int day_of month)
27 // **********found**********
28 _____
29 {
30 this->id=id;
31 }
32 void finish(Date date){
33 if(check(date))
34 //**********found**********
35 cout<<______<
36 else
37 cout<<"Time out."<
38 }
39 bool check(Date date){
40 //**********found**********
41 return______;
42 }
43 };
44 int main(){
45 Deadline*d1=new Deadline(1,2014,3,12);
46 Deadline*d2=new Deadline(2,2013,12,2 0);
47 Date current time(2014,1,1);
48 d1->finish(current time);
49 d2->finish(current time);
50 delete d1;
51 delete d2;
52 return 0;
53 }
选项
答案
(1)retum true (2):end_date(year,month,day_of_month) (3)"Finshed" (4)(end_date<=date)?false:true
解析
(1)根据题设可知比较两个日期的大小,由if语言的判断,可知this的日期大于date,返回真。
(2)构造函数的初始化列表,使用基类的构造函数完成子类成员的初始化。
(3)根据题意可知,没有超过deadline,故输出"Finshed"。
(4)检查当前日期是否超过截止时间。超过deadline,返回false,否则返回true。
转载请注明原文地址:https://kaotiyun.com/show/Poyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列关于运算符重载的叙述中,正确的是
若有定义语句"doublea=2/3.0;",则语句"cout
有如下类声明:classHow{intk;public:~How(){cout
使用VC6打开考生文件夹下的源程序文件modi2.epp。阅读下列函数说明和代码,实现函数sort(intA[],intn),用选择排序法把数组从大到小排序。提示:选择排序法的思想是:(1)反复从还未排好的那部分线性表中选择出关键字最小的节点;
设有表示公司和员工及雇佣的三张表,员工可在多家公司兼职,其中公司C(公司号,公司名,地址,注册资本,法人代表,员工数),员工S(员工号,姓名,性别,年龄,学历),雇佣E(公司号,员工号,工资,工作起始时间)。其中表C的键为公司号,表S的键为员工号,则表E的
下列字符中,可以出现在合法的C++标识符中的是
设循环队列为Q(1:m),其初始状态为front=rear=m。经过一系列入队与退队运算后,front=30,rear=10。现要在该循环队列中作顺序查找,最坏情况下需要比较的次数为
设二叉树如下:则前序序列为
下面描述中,不属于软件危机表现的是( )。
在下列枚举符号中,用来定位文件开始位置的方式是
随机试题
冲击试验的标准试样横截面尺寸一般为()。
关于正常人二尖瓣口血流频谱的描述,不正确的是()。
苯丙酮尿症的临床特点有()。
在担保贷款中,担保企业作为第三者要以其财产对借款企业的还贷能力予以担保,但不可以用信誉来担保。()
下列关于一般公司债券发行的表述中,正确的有()。
2×20年12月31日,甲公司因以公允价值计量且其变动计入当期损益的金融资产和以公允价值计量且其变动计入其他综合收益的金融资产的公允价值变动,分别确认了20万元的递延所得税资产和40万元的递延所得税负债。甲公司当期应交所得税的金额为200万元。假定不考虑其
促进学习迁移的有效教学措施有()。
某地发生了学生饮用豆奶中毒事件,当地政府采取“捂”的方式,且不允许家长到外地治疗,导致上百家长到北京求医,后在媒体介入下,发现了有上千学生中毒,引起社会广泛关注。请据此回答问题:如果让你负责此事,你会如何去处理善后工作?
(1)计入黑名单(2)利用信用卡网上套现(3)拒绝提供服务(4)引起网上支付公司重视(5)媒体新闻报道
HighintheMojavedesert,130milesnortheastofLosAngeles,liesavastfieldofmirrors.Crisscrossingrowsofglassandmet
最新回复
(
0
)