[计算机类试卷]国家二级C++机试(操作题)模拟试卷30及答案与解析.doc

上传人:livefirmly316 文档编号:497388 上传时间:2018-11-28 格式:DOC 页数:5 大小:32KB
下载 相关 举报
[计算机类试卷]国家二级C++机试(操作题)模拟试卷30及答案与解析.doc_第1页
第1页 / 共5页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷30及答案与解析.doc_第2页
第2页 / 共5页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷30及答案与解析.doc_第3页
第3页 / 共5页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷30及答案与解析.doc_第4页
第4页 / 共5页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷30及答案与解析.doc_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家二级 C+机试(操作题)模拟试卷 30及答案与解析 一、基本操作题 1 使用 VC6打开考生文件夹下的源程序文件 modil cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: Number=7 Numbe=12 注意:错误的语句在 *error*的下面,修改该语句即可。 1 #include 2 class CMyClass 3 4 public: 5 *error* 6 CMyClass(int i): Number=i 7 8 *error* 9 return Number ; 10 11 void set(int i) 12 13 Number=i ; 14 15

2、 void display() 16 17 coutdisplay(); 27 P-set(12); 28 P-display(); 29 return; 30 二、简单应用题 2 使用 VC6打开考生文件夹下的源程序文件 modi2 cpp。阅读下列函数说明和代码,补充空出的代码。 sum(int n)计算所有 n的因子之和 (不包括 1和自身 )。 注意:不能修改程序的其他部分,只能补充 sum()函数。 1 #include 2 int sum(int n) 3 4 5 6 void main() 7 8 cout 2 *1* 3 4 class objA0 5 6 private: 7

3、 static int m_A0; 8 *2* 9 10 ; 11 int objA0: m_A0=10 ; 12 class objAl 13 14 private: 15 int m_A1 ; 16 *3* 17 18 public: 19 obj A1(int i) 20 21 m_A1=i ; 22 23 ; 24 int func(objAl&obj) 25 26 *4* 27 28 29 int mein() 30 31 objA1 obj 0(1 0); 32 COUt: ”,因此第 1个标识下应添加 “class obiAl; ”。 (2)按照友元 的定义格式,友元函数是在类声

4、明中由关键字 friend修饰的非成员函数, func函数在类外部给出了具体的实现形式,即 “int func(objAl&obj)”,因此第 2个标识下应添加 “friend int func(objAl&obj); ”,这里参数是 objAl类对象obi。 (3)第 3个标识下和题目 2要求一样,均是声明友元函数,因此第 2标识下应添加 “friend int func(0bjAl&obj); ”。 (4)通过参数 Obj对象可以直接访问 obj.mA1, objA0的静态变量 m A0是所 有对象的共享成员,其访问形式为: objA0: m A0,因此第 4个标识下应添加“retum obj m Al*objA0: m_A0; ”。

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 3717-1991 Aerospace Series Tubes Selection for Engines Fluid Systems Issue P 1《航空航天系列.引擎防冻液管材选择.P1版》.pdf AECMA PREN 3717-1991 Aerospace Series Tubes Selection for Engines Fluid Systems Issue P 1《航空航天系列.引擎防冻液管材选择.P1版》.pdf
  • AECMA PREN 3718-1996 Aerospace Series Test Method for Metallic Materials Ultrasonic Inspection of Tubes Edition P 1《航空航天系列.铝或铝合金电缆导体产品标准.P2版》.pdf AECMA PREN 3718-1996 Aerospace Series Test Method for Metallic Materials Ultrasonic Inspection of Tubes Edition P 1《航空航天系列.铝或铝合金电缆导体产品标准.P2版》.pdf
  • AECMA PREN 3719-2009 Aerospace series Aluminium or aluminium alloy conductors for electrical cables Product standard Edition P 3《航空航天系列.电缆的铝或铝合金导体的产品标准.版本P3》.pdf AECMA PREN 3719-2009 Aerospace series Aluminium or aluminium alloy conductors for electrical cables Product standard Edition P 3《航空航天系列.电缆的铝或铝合金导体的产品标准.版本P3》.pdf
  • AECMA PREN 3720-1991 Aerospace Series Nuts Bihexagonal Self-Locking in Heat Resisting Steel FE-PA92HT (A286) MoS2 Coated Classification 1100 MPa (at Ambient Temperature) 425 Degree.pdf AECMA PREN 3720-1991 Aerospace Series Nuts Bihexagonal Self-Locking in Heat Resisting Steel FE-PA92HT (A286) MoS2 Coated Classification 1100 MPa (at Ambient Temperature) 425 Degree.pdf
  • AECMA PREN 3721-1991 Aerospace Series Nuts Bihexagonal Self-Locking Deep Counterbored in Heat Resisting Steel FE-PA92HT (A286) MoS2 Coated Classification 1100 MPa (at Ambient Tempe.pdf AECMA PREN 3721-1991 Aerospace Series Nuts Bihexagonal Self-Locking Deep Counterbored in Heat Resisting Steel FE-PA92HT (A286) MoS2 Coated Classification 1100 MPa (at Ambient Tempe.pdf
  • AECMA PREN 3722-1991 Aerospace Series Shank Nuts Self-Locking in Heat Resisting Steel FE-PA92HT (A286) MoS2 Coated Classification 1100 MPa (at Ambient Temperature) 425 Degrees C Is.pdf AECMA PREN 3722-1991 Aerospace Series Shank Nuts Self-Locking in Heat Resisting Steel FE-PA92HT (A286) MoS2 Coated Classification 1100 MPa (at Ambient Temperature) 425 Degrees C Is.pdf
  • AECMA PREN 3723-1991 Aerospace Series Nuts Hexagonal Self-Locking in Heat Resisting Steel FE-PA92HT (A286) MoS2 Coated Classification 1100 MPa (at Ambient Temperature) 425 Degrees .pdf AECMA PREN 3723-1991 Aerospace Series Nuts Hexagonal Self-Locking in Heat Resisting Steel FE-PA92HT (A286) MoS2 Coated Classification 1100 MPa (at Ambient Temperature) 425 Degrees .pdf
  • AECMA PREN 3724-1992 Aerospace Series Bolts Double Hexagon Head Relieved Shank Long Thread in Titanium Alloy TI-P63 MoS2 Coated Classification 1 100 MPa (at Ambient Temperature) Is.pdf AECMA PREN 3724-1992 Aerospace Series Bolts Double Hexagon Head Relieved Shank Long Thread in Titanium Alloy TI-P63 MoS2 Coated Classification 1 100 MPa (at Ambient Temperature) Is.pdf
  • AECMA PREN 3725-1997 Aerospace Series Bolts Pan Head Six Lobe Recess Normal Shank Long Thread in Titanium Alloy TI-P63 MoS2 Coated Classification 1 100 MPa (at Ambient Temperature).pdf AECMA PREN 3725-1997 Aerospace Series Bolts Pan Head Six Lobe Recess Normal Shank Long Thread in Titanium Alloy TI-P63 MoS2 Coated Classification 1 100 MPa (at Ambient Temperature).pdf
  • 相关搜索

    当前位置:首页 > 考试资料 > 职业资格

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1