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

上传人:proposalcash356 文档编号:497175 上传时间:2018-11-28 格式:DOC 页数:7 大小:32KB
下载 相关 举报
[计算机类试卷]国家二级C++机试(操作题)模拟试卷118及答案与解析.doc_第1页
第1页 / 共7页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷118及答案与解析.doc_第2页
第2页 / 共7页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷118及答案与解析.doc_第3页
第3页 / 共7页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷118及答案与解析.doc_第4页
第4页 / 共7页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷118及答案与解析.doc_第5页
第5页 / 共7页
点击查看更多>>
资源描述

1、国家二级 C+机试(操作题)模拟试卷 118及答案与解析 一、基本操作题 1 使用 VC6打开考生文件夹下的源程序文件 modil cpp,使它能得出正确的结果。 本程序要求屏幕输出: n=99 注意:不要改动 main函数,不能增行或删行,也不能更改程序的结构,错误的语句在 *error*的下面。 #include *error* class TestClasS() public: *error* voidTestClass(); TestClass(int n) cout #inciude #define NAXLEN 1024 char* convert (char*des, char*

2、 sir) void main() char dest; NAXI,EN; char*string=“abc def ”; cout; using namespace std; class TestClassl public: void print() cout=0 ; i一一 ) if(stri!=-) 判断结 尾是否有空格,从后往前判断直到不是 不是 空格了跳出循环 break ; for(1ength=0; lengthprint(); 【试题解析】 本题的功能是通过 print虚函数将字符串输出。在 VC环境下打开程序,根据题干给出的几条功能要求,对程序中给出注释下的内容逐个补全或修改

3、从已定源程序的 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; ”。

展开阅读全文
相关资源
猜你喜欢
  • ANSI UL 248-3-2000 UL Standard for Safety Low-Voltage Fuses C Part 3 Class CA and CB Fuses (Second Edition Reprint with Revisions Through and Including November 20 2014).pdf ANSI UL 248-3-2000 UL Standard for Safety Low-Voltage Fuses C Part 3 Class CA and CB Fuses (Second Edition Reprint with Revisions Through and Including November 20 2014).pdf
  • ANSI UL 248-4-2000 UL Standard for Safety Low-Voltage Fuses C Part 4 Class CC Fuses (Second Edition Reprint with Revisions Through and Including December 1 2014).pdf ANSI UL 248-4-2000 UL Standard for Safety Low-Voltage Fuses C Part 4 Class CC Fuses (Second Edition Reprint with Revisions Through and Including December 1 2014).pdf
  • ANSI UL 248-5-2000 UL Standard for Safety Low-Voltage Fuses C Part 5 Class G Fuses (Second Edition Reprint with Revisions Through and Including January 05 2015).pdf ANSI UL 248-5-2000 UL Standard for Safety Low-Voltage Fuses C Part 5 Class G Fuses (Second Edition Reprint with Revisions Through and Including January 05 2015).pdf
  • ANSI UL 248-6-2000 UL Standard for Safety Low-Voltage Fuses C Part 6 Class H Non-Renewable Fuses (Second Edition Reprint with Revisions Through and Including January 5 2015).pdf ANSI UL 248-6-2000 UL Standard for Safety Low-Voltage Fuses C Part 6 Class H Non-Renewable Fuses (Second Edition Reprint with Revisions Through and Including January 5 2015).pdf
  • ANSI UL 248-7-2000 UL Standard for Safety Low-Voltage Fuses C Part 7 Class H Renewable Fuses (Second Edition Reprint with Revisions Through and Including February 9 2015).pdf ANSI UL 248-7-2000 UL Standard for Safety Low-Voltage Fuses C Part 7 Class H Renewable Fuses (Second Edition Reprint with Revisions Through and Including February 9 2015).pdf
  • ANSI UL 248-8-2011 UL Standard for Safety Low-Voltage Fuses - Part 8 Class J Fuses (Third Edition Reprint with Revisions Through and Including August 18 2015)《低压保险丝安全标准.第8部分 J级保险丝》.pdf ANSI UL 248-8-2011 UL Standard for Safety Low-Voltage Fuses - Part 8 Class J Fuses (Third Edition Reprint with Revisions Through and Including August 18 2015)《低压保险丝安全标准.第8部分 J级保险丝》.pdf
  • ANSI UL 248-9-2000 UL Standard for Safety Low-Voltage Fuses C Part 9 Class K Fuses (Second Edition Reprint with Revisions Through and Including March 24 2015).pdf ANSI UL 248-9-2000 UL Standard for Safety Low-Voltage Fuses C Part 9 Class K Fuses (Second Edition Reprint with Revisions Through and Including March 24 2015).pdf
  • ANSI UL 25-2016 UL Standard for Safety Meters for Flammable and Combustible Liquids and LP-Gas (Ninth Edition Reprint with revisions through and including October 7 2016).pdf ANSI UL 25-2016 UL Standard for Safety Meters for Flammable and Combustible Liquids and LP-Gas (Ninth Edition Reprint with revisions through and including October 7 2016).pdf
  • ANSI UL 2515-2009 UL Standard for Safety Aboveground Reinforced Thermosetting Resin Conduit (RTRC) and Fittings (First Edition Reprint with revisions through and including January .pdf ANSI UL 2515-2009 UL Standard for Safety Aboveground Reinforced Thermosetting Resin Conduit (RTRC) and Fittings (First Edition Reprint with revisions through and including January .pdf
  • 相关搜索

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

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