【计算机类职业资格】C++语言笔试-7及答案解析.doc
《【计算机类职业资格】C++语言笔试-7及答案解析.doc》由会员分享,可在线阅读,更多相关《【计算机类职业资格】C++语言笔试-7及答案解析.doc(5页珍藏版)》请在麦多课文档分享上搜索。
1、C+语言笔试-7 及答案解析(总分:100.00,做题时间:90 分钟)一、操作题(总题数:3,分数:100.00)1.请使用 VC6 或使用答题菜单打开考生文件夹 proj1 下的工程 proj1。程序中位于每个“/ERROR *found*”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:value=63number=1注意:只修改每个“/ERROR *found*”下的那一行,不要改动程序中的其他内容。#include iostreamusing namespace std;class MyClass int*p;const int N;public:/ERROR *foun
2、d*MyClass(int val):N=1p=new int;*p=val;/ERROR *found*MyClass() delete*p;friend void print(MyClass;/ERROR *found*void MyClass:print(MyClasscout“number=“obj.Nendl;int main()MyClass obj(63);print(obj);return 0;(分数:30.00)_2.请使用 VC6 或使用答题菜单打开考生文件夹 proj2 下的工程 proj2,其中定义了 Component 类、Composite 类和 Leaf 类。Co
3、mponent 是抽象基类,Composite 和 Leaf 是 Component 的公有派生类。请在横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为:Leaf Node注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“/ *found*”。#includeiostreamusing namespace std;class Componentpublic:/声明纯虚函数 print()/*found*;class Composite:public Componentpublic:/*found*void setChild(_)m_chil
4、d=child;virtual void print()constm_child-print();private:Component*m_child;class Leaf:public Componentpublic:virtual void print()const/*found*_;int main()Leaf node;Composite comp;comp.setChild(Component*p=p-print();return 0;(分数:30.00)_3.请使用 VC6 或使用答题菜单打开考生文件夹 proj3 下的工程 proj3,其中定义的 Matrix 是一个用于表示矩阵的
5、类。成员函数 max_value 的功能是求出所有矩阵元素中的最大值。例如,若有 33 矩阵(分数:40.00)_C+语言笔试-7 答案解析(总分:100.00,做题时间:90 分钟)一、操作题(总题数:3,分数:100.00)1.请使用 VC6 或使用答题菜单打开考生文件夹 proj1 下的工程 proj1。程序中位于每个“/ERROR *found*”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:value=63number=1注意:只修改每个“/ERROR *found*”下的那一行,不要改动程序中的其他内容。#include iostreamusing namespace
6、 std;class MyClass int*p;const int N;public:/ERROR *found*MyClass(int val):N=1p=new int;*p=val;/ERROR *found*MyClass() delete*p;friend void print(MyClass;/ERROR *found*void MyClass:print(MyClasscout“number=“obj.Nendl;int main()MyClass obj(63);print(obj);return 0;(分数:30.00)_正确答案:(1)MyClass(int val):N
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
5000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 职业资格 语言 笔试 答案 解析 DOC
