问答题
请使用VC6或使用【答题】菜单打开考生文件夹pmjl下的工程proj1。此工程中包括类Date(“13期”)和主函数main的定义。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:2006-1-12005-12-312005-1-312006-1-1注意:只修改每个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。#include<iostream>usingnamespaeestd;clasSDate{public:Date(inty=2006,intm=1,intd=1)//ERROR"/*********found*********:year=y,month=m,day=d{}//ERROR*********found*********Date(constDated){this->year=d.year;this->month=d.month;this->day=d.day;}voidprint()const{cout<<year<<’一’<<month<<’一’<<day<<end1;}private://ERROR*********found*********intyear(2006),month(1),day(1);};intmain(){Datedl,d2(2005,12,31),d3;d1.print:();d2.print:();c13=d2;c12=d1;d1=d3;d1.print();d2.print();return0;}
【参考答案】
正确答案:(1): year(y), month(m), day(d) (2)Date(const Date & d) ......
(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)