【计算机类职业资格】国家二级C++机试(操作题)-试卷130及答案解析.doc

上传人:孙刚 文档编号:1331723 上传时间:2019-10-17 格式:DOC 页数:3 大小:32KB
下载 相关 举报
【计算机类职业资格】国家二级C++机试(操作题)-试卷130及答案解析.doc_第1页
第1页 / 共3页
【计算机类职业资格】国家二级C++机试(操作题)-试卷130及答案解析.doc_第2页
第2页 / 共3页
【计算机类职业资格】国家二级C++机试(操作题)-试卷130及答案解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家二级 C+机试(操作题)-试卷 130 及答案解析(总分:6.00,做题时间:90 分钟)一、基本操作题(总题数:1,分数:2.00)1.使用 VC6 打开考生文件夹下的源程序文件 modilcpp,使它能得出正确的结果。 本程序要求屏幕输出:n=99 注意:不要改动 main 函数,不能增行或删行,也不能更改程序的结构,错误的语句在*error*的下面。 #include *error* class TestClasS() public: *error* voidTestClass(); TestClass(int n) coutprint();)解析:解析:本题的功能是通过 print

2、 虚函数将字符串输出。在 VC 环境下打开程序,根据题干给出的几条功能要求,对程序中给出注释下的内容逐个补全或修改。从已定源程序的 main 主函数开始入手,可以看出程序通过调用类和成员函数实现各种输出操作。 解题思路 (1)题目 1 要求“类 TestClass2 公共继承于 TestClassl”。从已有的类产生一个新的子类,成为类的派生。声明派生类的一般形式为:class 派生类名:继承方式基类名。根据题目中的要求以及派生类的一般形式,第 1 个标识下添加语句“class TestClass2:public TestClass 1”。 (2)题目 2 要求“print 函数为虚函数”。在 C+中,用 virtual声明的函数为虚函数,因此第 2 个标识下的语句修改为“vimlal voidprint()”。 (3)题目 3 要求“使得P 指定对象 obj3”。P 为指针变量,obj3 为类的对象,将一个指针变量指向另一个变量,只要把被指向的变量的地址赋给指针变量即可。取对象 obj3 地址的语句为&obj3,所以这里补全“p=&obj3;”。 (4)题目 4 要求“利用 P 调用 print()函数”。C+中用”-运算符实现成员访问,因此调用 print()函数,应将第 4 个标识下修改为“p-print0;”。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 61249-7-1-1996 Materials for interconnection structures - Part 7 Sectional specification set for restraining core materials section 1 Copper Invar copper (IEC 61249-7-1 1995.pdf DIN EN 61249-7-1-1996 Materials for interconnection structures - Part 7 Sectional specification set for restraining core materials section 1 Copper Invar copper (IEC 61249-7-1 1995.pdf
  • DIN EN 61249-8-7-1997 Materials for interconnection structures - Part 8 Sectional specification set for non-conductive films and coatings section 7 Marking legend inks (IEC 61249-8.pdf DIN EN 61249-8-7-1997 Materials for interconnection structures - Part 8 Sectional specification set for non-conductive films and coatings section 7 Marking legend inks (IEC 61249-8.pdf
  • DIN EN 61249-8-8-1998 Materials for interconnection structures - Part 8 Sectional specification set for non-conductive films and coatings Section 8 Temporary polymer coatings (IEC .pdf DIN EN 61249-8-8-1998 Materials for interconnection structures - Part 8 Sectional specification set for non-conductive films and coatings Section 8 Temporary polymer coatings (IEC .pdf
  • DIN EN 61254-1994 Electric shavers for household use - Methods for measuring the performance (IEC 61254 1993) German version EN 61254 1994《家用电动剃须刀 性能测量方法》.pdf DIN EN 61254-1994 Electric shavers for household use - Methods for measuring the performance (IEC 61254 1993) German version EN 61254 1994《家用电动剃须刀 性能测量方法》.pdf
  • DIN EN 61260-1-2014 Electroacoustics - Octave-band and fractional-octave-band filters - Part 1 Specifications (IEC 61260-1 2014) German version EN 61260-1 2014《电声学 倍频程频带和分倍频程频带滤波器 .pdf DIN EN 61260-1-2014 Electroacoustics - Octave-band and fractional-octave-band filters - Part 1 Specifications (IEC 61260-1 2014) German version EN 61260-1 2014《电声学 倍频程频带和分倍频程频带滤波器 .pdf
  • DIN EN 61260-3-2016 Electroacoustics - Octave-band and fractional-octave-band filters - Part 3 Periodic tests (IEC 61260-3 2016) German version EN 61260-3 2016《电声学 分倍频程带和倍频程带滤波器 第3.pdf DIN EN 61260-3-2016 Electroacoustics - Octave-band and fractional-octave-band filters - Part 3 Periodic tests (IEC 61260-3 2016) German version EN 61260-3 2016《电声学 分倍频程带和倍频程带滤波器 第3.pdf
  • DIN EN 61262-1-1995 Medical electrical equipment - Characteristics of electro-optical X-ray image intensifiers - Part 1 Determination of the entrance field size (IEC 61262-1 1994) .pdf DIN EN 61262-1-1995 Medical electrical equipment - Characteristics of electro-optical X-ray image intensifiers - Part 1 Determination of the entrance field size (IEC 61262-1 1994) .pdf
  • DIN EN 61262-2-1995 Medical electrical equipment - Characteristics of electro-optical X-ray image intensifiers - Part 2 Determination of the conversion factor (IEC 61262-2 1994) Ge.pdf DIN EN 61262-2-1995 Medical electrical equipment - Characteristics of electro-optical X-ray image intensifiers - Part 2 Determination of the conversion factor (IEC 61262-2 1994) Ge.pdf
  • DIN EN 61262-3-1995 Medical electrical equipment - Characteristics of electro-optical X-ray image intensifiers - Part 3 Determination of the luminance distribution and luminance no.pdf DIN EN 61262-3-1995 Medical electrical equipment - Characteristics of electro-optical X-ray image intensifiers - Part 3 Determination of the luminance distribution and luminance no.pdf
  • 相关搜索

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

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