[计算机类试卷]国家二级C++机试(操作题)模拟试卷205及答案与解析.doc
《[计算机类试卷]国家二级C++机试(操作题)模拟试卷205及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级C++机试(操作题)模拟试卷205及答案与解析.doc(9页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级 C+机试(操作题)模拟试卷 205及答案与解析 一、基本操作题 1 请使用 VC6或使用【答题】菜单打开考生文件夹 proj1下的工程 proj1。该工程中包含程序文件 main cpp,其中有类 CDate(“日期 ”)和主函数 main的定义。程序中位于每个 “ ERROR*found*”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: 原日期: 2005-9-25 更新后的日期: 2006-4-1 注意:只修改每个 “ ERROR*found*”下的那一行,不要改动程序中的其他内容。 1 #iFtC2ude 2 #iD Clude 3 usingr namespac
2、e std; 4 5 class CDate日期类 6 7 ERROR * found* 8 protected: 9 CDate(); 10 CDate(int d, int m, int y) 11 12 ERROR *found* 13 SetDate(int day=d, int month=m, int year=y); 14 ; 15 void Di splay();显示日期 16 void Set: Date(int day, int month, int year) 17 设置日期 18 m_nDay=day;m nMonth=month; mnYear=year; 19 pr
3、ivate: 20 intm_nDay;日 21 int_m nMonth;月 22 int m_nYear;年 23 ; 24 25 void CDate: Display()显示日期 26 27 ERROR *found* 28 cout 2 using namespace std; 3 class Date 日期类 4 int year,month,day;年、月、日 5 public: 6 Date(int year, int month, int day): year(year), month(month), day(day) 7 int getYear()constreturn y
4、ear; 8 int getMonth()constreturn month; 9 int getDay()constreturn day; 10 ; 11 class Person 人员类 12 char name14;姓名 13 bool is male;性别,为 true时表示男性 14 Date birth date;出生日期 15 public: 16 Person(char*name, bool is_male, Date birth_date) 17 *found* 18 : _ 19 20 strcpy(this-name, name); 21 22 const char*ge
5、tName()constre-turn name; 23 bool isMale()constreturn is male; 24 Date getBirthdate()const return birth_date; 25 利用 strcmp()函数比较姓名,返回一个正数、 0或负数,分别表示大于、等于、小于 26 int compareName(const Person p)const 27 *found* 28 _; 29 void show() 30 couti) 46 Person p=psm; 47 psm=psi; 48 psi=P; 49 50 51 52 53 int mai
6、n() 54 Person staff= 55 Person(“张三 “, true, Date(1978, 4, 2 0), 56 Person(“王五 “, false, Date(1965, 8, 3), 57 Person(“杨六 “, false, Date(1965, 9, 5), 58 Person(“李四 “, true, Date(1973, 5, 3 0) 59 ; 60 const int size=sizeof(staff) si-zeof(staff0); 61 int i; 62 cout 3 using namespace std; 4 class Person
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 机试 操作 模拟 205 答案 解析 DOC
