[计算机类试卷]国家二级C++机试(操作题)模拟试卷208及答案与解析.doc
《[计算机类试卷]国家二级C++机试(操作题)模拟试卷208及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级C++机试(操作题)模拟试卷208及答案与解析.doc(6页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级 C+机试(操作题)模拟试卷 208及答案与解析 一、基本操作题 1 请使用 VC6或使用【答题】菜单打开考生文件夹 proj1下的工程 proj1。程序中位于每个 “ ERROR*found*”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: value=63 number=1 注意:只修改每个 “ ERROR*found*”下的那一行,不要改动程序中的其他内容。 1 #include 2 using namespace std; 3 4 class MyClasS 5 int*p; 6 const int N; 7 public: 8 ERROR * found* 9
2、MyClas S(int val): N=1 10 11 p=new int; 12 *p=val; 13 14 ERROR *found* 15 MyClass()delete*p; ) 16 friend void print(MyClass obj); 17 ; 18 ERROR *found* 19 void MyClass: print(MyClasS obj) 20 21 cout “value=“ 2 #include 3 using namespace std; 4 class MyString 5 6 private: 7 char*str; 8 public: 9 MySt
3、ring(char*s) 10 11 *found* 12 str=new_; 13 strcpy(str, s); 14 15 MyString() 16 17 *found* 18 _; 19 20 char 22 char 27 *found* 28 return_; 29 30 int main() 31 32 MyString test(“test string“); 33 cout=2007-06-19 2007-06-21=“; 6 date2 show(); cout=“; 9 date3 show(); cout= “; 12 date4 show(); cout 3 #in
4、clude 4 using namespace std; 5 class Date 6 int year; 7 int month; 8 int day; 9 public: 10 Date(int y, int m, int d): year 11 (y), month(m), day(d)int getYear()constreturn year; 12 int getMonth()const return month; 13 int getDay()constreturn day; 14 void show(ostream 15 bool operator=: (Date date)co
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 机试 操作 模拟 208 答案 解析 DOC
