[计算机类试卷]国家二级C++机试(操作题)模拟试卷38及答案与解析.doc
《[计算机类试卷]国家二级C++机试(操作题)模拟试卷38及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级C++机试(操作题)模拟试卷38及答案与解析.doc(7页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级 C+机试(操作题)模拟试卷 38及答案与解析 一、基本操作题 1 使用 VC6打开考生文件夹下的源程序文件 modil cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: Numbe=8 注意:错误的语句在 *error*的下面,修改该语句即可。 1 #include 2 class CMyClass 3 4 public: 5 *error* 6 void&Get() 7 8 return&Number; 9 10 void Set(int m) 11 12 Number=m; 13 14 void display() 15 16 cout 2 #include
2、3 #include 4 USing namespace std; 5 void WriteFile(int c) 6 7 ofstream outl; 8 outl open(“modi2 txt“, ios_base: binary ios_base: app); 9 outl 2 #include 3 #include 4 #include 5 using namespace std; 6 void WriteFile(int c) 7 8 ofstream out1 ; 9 outl open(“modi3 txt“, iosbase: app); 10 outl c ; 11 out
3、i close(); 12 13 void WriteFi le(char*str) 14 15 ofstream outl; 16 outl open(“modi3 txt“, los_base: app); 17 outlstr; 18 outl close(); 19 20 void ClearFile() 21 22 ofstream outl ; 23 outl open(”modi3 txt”); 24 outl close(); 25 26 class Date 27 28 public: 12 Date(int y, int m, int d) 30 31 *2* 32 33
4、34 void print()const ; 35 *3* 36 37 38 month+=m; 39 int i=month 12; 40 int J=month 12; 41 if(j=0) 42 43 year+=(i-1); 44 month=12; 45 46 else 47 48 year+=i; 49 month=j; 50 51 return *this ; 52 53 private: 54 *1* 55 56 ; 57 void Date: print()const 58 59 *4* 60 61 WriteFile(year); 62 WriteFile(“年 “); 6
5、3 WriteFile(month); 64 WriteFile(“月 “); 65 WriteFile(day); 66 WriteFile(“日 “); 67 68 int mein() 69 70 ClearFile(); 71 Date Oly_day(2008, 8, 8); 72 Oly_day+=3 ; 73 OIy_day print(); 74 return 0; 75 国家二级 C+机试(操作题)模拟试卷 38答案与解析 一、基本操作题 1 【正确答案】 (1)void*Get() (2)添加语句: CMyClass t ; (3)P=(int*)t Get(); 【试题解
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 机试 操作 模拟 38 答案 解析 DOC
