欢迎来到麦多课文档分享! | 帮助中心 海量文档,免费浏览,给你所需,享你所想!
麦多课文档分享
全部分类
  • 标准规范>
  • 教学课件>
  • 考试资料>
  • 办公文档>
  • 学术论文>
  • 行业资料>
  • 易语言源码>
  • ImageVerifierCode 换一换
    首页 麦多课文档分享 > 资源分类 > DOC文档下载
    分享到微信 分享到微博 分享到QQ空间

    【计算机类职业资格】二级C++-64及答案解析.doc

    • 资源ID:1324120       资源大小:40.50KB        全文页数:4页
    • 资源格式: DOC        下载积分:5000积分
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    二维码
    微信扫一扫登录
    下载资源需要5000积分(如需开发票,请勿充值!)
    邮箱/手机:
    温馨提示:
    如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如需开发票,请勿充值!如填写123,账号就是123,密码也是123。
    支付方式: 支付宝扫码支付    微信扫码支付   
    验证码:   换一换

    加入VIP,交流精品资源
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    【计算机类职业资格】二级C++-64及答案解析.doc

    1、二级 C+-64及答案解析(总分:100.00,做题时间:90 分钟)一、B基本操作题/B(总题数:1,分数:30.00)1.请使用 VC6或使用答题菜单打开考生文件夹 proj1下的工程 proj1。程序中位于每个“/ERROR *found*”之后的一行语句有错误,请加以改正。改正后程序的输出结果应该是: Name:Smith Age:21 ID:99999 CourseNum:12 Record:970 注意:只修改每个“/ERROR *found*”下的一行,不要改动程序中的其他内容。 #include iostream using namespace std; class Stude

    2、ntInfo protected: / ERROR * found* char Name; int Age; int ID; int CourseNum; float Record; public: / ERROR * found* void StudentInfo(char * name, int age, int ID, int courseNum, float record); / ERROR * found* void StudentInfo () delete Name; float AverageRecord() return Record/CourseNum; void show

    3、()const; ; StudentInfo:StudentInfo (char *name, int age, int ID, int courseNum,float record) Name = strdup(name); Age = age; this-ID = ID; CourseNum = courseNum; Record = record; void StudentInfo:show()const cout “Name: “ Name “Age: “ Age“ID: “ ID “CourseNum: “ CourseNum “Record: “ Record endl; int

    4、main() StudentInfo st (“Smith“, 21, 99999, 12, 970); st.show(); return 0; (分数:30.00)_二、B简单应用题/B(总题数:1,分数:30.00)2.请使用 VC6或使用答题菜单打开考生文件夹 proj2下的工程 proj2,其中包含抽象类 Shape的声明,以及在此基础上派生出的类 Rectangle和 Circle的声明,二者都有计算对象面积的函数 GetArea()和计算对象周长的函数 GetPerim()。程序中位于每个“/*found*”之后的一行语句有错误,请加以改正。改正后程序的输出结果应该是: The

    5、area ofthe Circle is 78.5 The perimeter of the Circle is 31.4 The area of the Rectangle is 24 The perimeter of the Rectangle is 20 注意:只在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“/*found*”。 #include iostream using namespace std; class Shape public: Shape() Shape() /* found* _float GetArea() =0; /* found* _flo

    6、at GetPerim () =0; ; class Circle : public Shape public: Circle (float radius): itsRadius (radius) Circle() float GetArea () return 3.14 * itsRadius * itsRadius; float GetPerim () return 6.28 * itsRadius; private: float itsRadius; ; class Rectangle : public Shape public: /* found* Rectangle(float le

    7、n, float width): _; Rectangle(); virtual float GetArea() return itsLength * itsWidth; float GetPerim () return 2 * itsLength + 2 * itsWidth; virtual float GetLength() return itsLength; virtual float GetWidth () return itsWidth; private: float itsWidth; float itsLength; ; int main() /* found* _ sp =

    8、new Circle(5); cout “The area of the Circle is“ sp-GetArea () endl; cout “The perimeter of the Circle is“ sp-GetPerim () endl; delete sp; sp = new Rectangle(4, 6); cout “The area of the Rectangleis“ sp-GetArea() endl; cout “The perimeter of the Rectangle is“ sp - GetPerim () endl; delete sp; return

    9、0; (分数:30.00)_三、B综合应用题/B(总题数:1,分数:40.00)3.请使用 VC6或使用答题菜单打开考生文件夹 proj3下的工程 proj3,其中声明的 CDeepCopy是一个用于表示动态数组的类。请编写其中的复制构造函数。 要求: 补充编制的内容写在“/*333*”与“/*666*”之间,不得修改程序的其他部分。 注意:程序最后将结果输出到文件 out.dat中。输出函数 writeToFile已经编译为 obj文件,并且在本程序中调用。/CDeepCopy.h #include iostream #include string using namespace std;

    10、class CDeepCopy public: int n; /动态数组的元素个数 int * p; /动态数组首地址 CDeepCopy (int); CDeepCopy (); CDeepCopy(const CDeepCopy /复制构造函数 ; void writeToFile (char * ); /main. cpp #include “CDeepCopy. h“ CDeepCopy: CDeepCopy () delete p; CDeepCopy:CDeepCopy (int k) n = k; p=new intn; CDeepCopy: CDeepCopy ( const

    11、CDeepCopy a.p0 =1; d.p0 =666; /对象 a,d 数组元素的赋值 CDeepCopy b (a); a.p0 =88; cout b.p0; /显示内层局部对象的数组元素 cout d.p0; /显示 d数组元素 a.p0的值 cout “ d fade away; /n“; cout a. pO; /显示 a数组元素 a.p0的值 writeToFile (“); return 0; (分数:40.00)_二级 C+-64答案解析(总分:100.00,做题时间:90 分钟)一、B基本操作题/B(总题数:1,分数:30.00)1.请使用 VC6或使用答题菜单打开考生文

    12、件夹 proj1下的工程 proj1。程序中位于每个“/ERROR *found*”之后的一行语句有错误,请加以改正。改正后程序的输出结果应该是: Name:Smith Age:21 ID:99999 CourseNum:12 Record:970 注意:只修改每个“/ERROR *found*”下的一行,不要改动程序中的其他内容。 #include iostream using namespace std; class StudentInfo protected: / ERROR * found* char Name; int Age; int ID; int CourseNum; floa

    13、t Record; public: / ERROR * found* void StudentInfo(char * name, int age, int ID, int courseNum, float record); / ERROR * found* void StudentInfo () delete Name; float AverageRecord() return Record/CourseNum; void show()const; ; StudentInfo:StudentInfo (char *name, int age, int ID, int courseNum,flo

    14、at record) Name = strdup(name); Age = age; this-ID = ID; CourseNum = courseNum; Record = record; void StudentInfo:show()const cout “Name: “ Name “Age: “ Age“ID: “ ID “CourseNum: “ CourseNum “Record: “ Record endl; int main() StudentInfo st (“Smith“, 21, 99999, 12, 970); st.show(); return 0; (分数:30.0

    15、0)_正确答案:(1)char*Name; (2)StudentInfo(char*name, int age, int ID, int courseNum, float record); (3)StudentInfo()deleteName;)解析:考点 本题考查 StudentInfo类,其中涉及构造函数、析构函数和成员函数。 解析 (1)根据构造函数的定义可知,Name 应定义为指针变量。 (2)主要考查考生对构造函数定义的掌握,构造函数前不能添加任何类型。 (3)主要考查考生对析构函数定义的掌握,析构函数前不能添加任何类型。二、B简单应用题/B(总题数:1,分数:30.00)2.请使用

    16、 VC6或使用答题菜单打开考生文件夹 proj2下的工程 proj2,其中包含抽象类 Shape的声明,以及在此基础上派生出的类 Rectangle和 Circle的声明,二者都有计算对象面积的函数 GetArea()和计算对象周长的函数 GetPerim()。程序中位于每个“/*found*”之后的一行语句有错误,请加以改正。改正后程序的输出结果应该是: The area ofthe Circle is 78.5 The perimeter of the Circle is 31.4 The area of the Rectangle is 24 The perimeter of the R

    17、ectangle is 20 注意:只在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“/*found*”。 #include iostream using namespace std; class Shape public: Shape() Shape() /* found* _float GetArea() =0; /* found* _float GetPerim () =0; ; class Circle : public Shape public: Circle (float radius): itsRadius (radius) Circle() float Ge

    18、tArea () return 3.14 * itsRadius * itsRadius; float GetPerim () return 6.28 * itsRadius; private: float itsRadius; ; class Rectangle : public Shape public: /* found* Rectangle(float len, float width): _; Rectangle(); virtual float GetArea() return itsLength * itsWidth; float GetPerim () return 2 * i

    19、tsLength + 2 * itsWidth; virtual float GetLength() return itsLength; virtual float GetWidth () return itsWidth; private: float itsWidth; float itsLength; ; int main() /* found* _ sp = new Circle(5); cout “The area of the Circle is“ sp-GetArea () endl; cout “The perimeter of the Circle is“ sp-GetPeri

    20、m () endl; delete sp; sp = new Rectangle(4, 6); cout “The area of the Rectangleis“ sp-GetArea() endl; cout “The perimeter of the Rectangle is“ sp - GetPerim () endl; delete sp; return 0; (分数:30.00)_正确答案:(1)virtual (2)virtual (3)itsLength(len),itsWidth(width) (4)Shape*sp;)解析:考点 本题考查抽象基类 Shape类及其派生类 C

    21、ircle和 Rectangle,其中涉及纯虚函数、构造函数、析构函数和成员函数。 解析 (1)和(2)主要考查考生对纯虚函数定义的掌握,纯虚函数前要添加关键字 virtual。 (3)主要考查考生对构造函数的掌握,使用成员列表初始化。 (4)主要考查考生对指针的掌握,由下一条语句:sp=new Circle(5);,可知 sp为 Shape型指针。三、B综合应用题/B(总题数:1,分数:40.00)3.请使用 VC6或使用答题菜单打开考生文件夹 proj3下的工程 proj3,其中声明的 CDeepCopy是一个用于表示动态数组的类。请编写其中的复制构造函数。 要求: 补充编制的内容写在“/

    22、*333*”与“/*666*”之间,不得修改程序的其他部分。 注意:程序最后将结果输出到文件 out.dat中。输出函数 writeToFile已经编译为 obj文件,并且在本程序中调用。/CDeepCopy.h #include iostream #include string using namespace std; class CDeepCopy public: int n; /动态数组的元素个数 int * p; /动态数组首地址 CDeepCopy (int); CDeepCopy (); CDeepCopy(const CDeepCopy /复制构造函数 ; void writeT

    23、oFile (char * ); /main. cpp #include “CDeepCopy. h“ CDeepCopy: CDeepCopy () delete p; CDeepCopy:CDeepCopy (int k) n = k; p=new intn; CDeepCopy: CDeepCopy ( const CDeepCopy a.p0 =1; d.p0 =666; /对象 a,d 数组元素的赋值 CDeepCopy b (a); a.p0 =88; cout b.p0; /显示内层局部对象的数组元素 cout d.p0; /显示 d数组元素 a.p0的值 cout “ d fa

    24、de away; /n“; cout a. pO; /显示 a数组元素 a.p0的值 writeToFile (“); return 0; (分数:40.00)_正确答案:(n=r.n; /把对象 r的成员变量 n赋值 给 n p=new intn; /给 p动态分配大小为 n的空间 for(int index=0; indexn; index+) /index 从零开始,小于 n为条件遍历 pindex=r.pindex; /把对象 r中的成员变量 pindex赋值给 pindex)解析:考点 本题考查 CDeepCopyr类,其中涉及动态数组、构造函数、析构函数和复制构造函数。 解析 主要考查考生对复制构造函数的掌握,复制构造函数要复制动态数组,应先使用 new分配空间,然后使用循环语句逐个复制,注意这里不能使用 strcpy函数复制,因为 p是整型动态数组。


    注意事项

    本文(【计算机类职业资格】二级C++-64及答案解析.doc)为本站会员(outsidejudge265)主动上传,麦多课文档分享仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文档分享(点击联系客服),我们立即给予删除!




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

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

    收起
    展开