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

上传人:jobexamine331 文档编号:1324790 上传时间:2019-10-17 格式:DOC 页数:13 大小:75.50KB
下载 相关 举报
【计算机类职业资格】二级C++笔试55及答案解析.doc_第1页
第1页 / 共13页
【计算机类职业资格】二级C++笔试55及答案解析.doc_第2页
第2页 / 共13页
【计算机类职业资格】二级C++笔试55及答案解析.doc_第3页
第3页 / 共13页
【计算机类职业资格】二级C++笔试55及答案解析.doc_第4页
第4页 / 共13页
【计算机类职业资格】二级C++笔试55及答案解析.doc_第5页
第5页 / 共13页
点击查看更多>>
资源描述

1、二级 C+笔试 55及答案解析(总分:90.00,做题时间:90 分钟)一、B选择题/B(总题数:30,分数:60.00)1.有以下程序: #include iostream using namespace std; class BASE private: char c; public: BASE(char n):c(n); virtualBASE() coutc; ; class DERIVED:public BASE char c; public: DERIVED(char n):BASE(n+1),c(n) DERIVED()coutc; ; int main() DERIVED obj

2、X); return 0; 执行上面的程序将输出( )。(分数:2.00)A.XYB.YXC.XD.Y2.下面程序的输出结果是( )。 #include iostream using namespace Std; int main() int x6=1,3,5,7,9,11,*k,*s; k=x; s=!x class Base int a; public: Base(int x) a-x; void show() couta; ; class Derived : public Base int b; public: Derived(int i) :Base(i+1) void show()

3、 coutb; ; int main ( ) Base b(5) ,*pb; Derived d(1); pb= pb-show (); return 0; 运行后的打印结果是U 【14】 /U。(分数:2.00)填空项 1:_45.执行如下程序后的输出结果是U 【15】 /U。 #include iostream #include fstream using namespace std; int main ( ) char s25; ofstream fl(“data.txt“); f1“C+ Programming“; f1.close (); ifstream f2 (“data.txt

4、); if (f2.good() f2s; f2.close(); couts; return 0; (分数:2.00)填空项 1:_二级 C+笔试 55答案解析(总分:90.00,做题时间:90 分钟)一、B选择题/B(总题数:30,分数:60.00)1.有以下程序: #include iostream using namespace std; class BASE private: char c; public: BASE(char n):c(n); virtualBASE() coutc; ; class DERIVED:public BASE char c; public: DERI

5、VED(char n):BASE(n+1),c(n) DERIVED()coutc; ; int main() DERIVED obj(X); return 0; 执行上面的程序将输出( )。(分数:2.00)A.XY B.YXC.XD.Y解析:解析 在 C+中,由于析构函数不能被继承,因此在执行派生类的析构函数时,基类的析构函数也将被调用。执行顺序是先执行派生类的析构函数,再执行基类的析构函数,其顺序与执行构造函数的顺序正好相反。在此题的程序中,在主函数结束时,派生类 DERIVED对象 obj将被删除,所以就会调用对象的析构函数。先调用派生类的析构函数,输出 X,然后调用基类的析构函数,输

6、出 Y。2.下面程序的输出结果是( )。 #include iostream using namespace Std; int main() int x6=1,3,5,7,9,11,*k,*s; k=x; s=!x class Base int a; public: Base(int x) a-x; void show() couta; ; class Derived : public Base int b; public: Derived(int i) :Base(i+1) void show() coutb; ; int main ( ) Base b(5) ,*pb; Derived d

7、1); pb= pb-show (); return 0; 运行后的打印结果是U 【14】 /U。(分数:2.00)填空项 1:_ (正确答案:2)解析:解析 本例程序中类 Derived是从基类 Base公有继承来的。主函数中定义了基类对象 b和一个基类指针 pb,又定义了派生类 Derived的对象 d。由于 Derived是 Base的子类型,因此可以将派生类Derived的对象 d的地址赋值给指向基类 Base的指针 pb,但这时指针 pb只能使用从基类 Base继承的成员。所以通过对象指针 pb调用的 show函数是基类的成员函数 show(),从而输出基类私有数据成员 a的值 2

8、45.执行如下程序后的输出结果是U 【15】 /U。 #include iostream #include fstream using namespace std; int main ( ) char s25; ofstream fl(“data.txt“); f1“C+ Programming“; f1.close (); ifstream f2 (“data.txt“); if (f2.good() f2s; f2.close(); couts; return 0; (分数:2.00)填空项 1:_ (正确答案:C+)解析:解析 程序先在当前目录下建立一个 data文本文件,并写入“C+ Programming”。然后打开该文件,将其中的数据输入到变量 s中,由于采用提取符“”读时遇到空格终止,所以最后字符数组 s中存放的是“C+”。

展开阅读全文
相关资源
猜你喜欢
  • EJ T 1196-2005 781 Specification for audio-frequency magnetotellurics survey on in-situ leaching sandstone type uranium deposits《地浸砂岩型铀矿音频大地电磁测量规范》.pdf EJ T 1196-2005 781 Specification for audio-frequency magnetotellurics survey on in-situ leaching sandstone type uranium deposits《地浸砂岩型铀矿音频大地电磁测量规范》.pdf
  • EJ T 1197-2007 431 Testing method and environment condition for qualification of electrical equipment of the safety system in nuclear power plants《核电厂安全级电气设备质量鉴定试验方法与环境条件》.pdf EJ T 1197-2007 431 Testing method and environment condition for qualification of electrical equipment of the safety system in nuclear power plants《核电厂安全级电气设备质量鉴定试验方法与环境条件》.pdf
  • EJ T 1198-2006 Nuclear power plants-Electrical interlocks for functions important to safety-Recommendations for design and implementation《核电厂安全重要功能电气连锁的设计和实施》.pdf EJ T 1198-2006 Nuclear power plants-Electrical interlocks for functions important to safety-Recommendations for design and implementation《核电厂安全重要功能电气连锁的设计和实施》.pdf
  • EJ T 1199-2007 781 Method of routine sampling for diuranate product《重铀酸盐产品常规取样方法》.pdf EJ T 1199-2007 781 Method of routine sampling for diuranate product《重铀酸盐产品常规取样方法》.pdf
  • EJ T 1200-2006 Safety criteria for decommissioning design of production reactor《生产堆退役设计安全准则》.pdf EJ T 1200-2006 Safety criteria for decommissioning design of production reactor《生产堆退役设计安全准则》.pdf
  • EJ T 1201-2006 Safety criteria for decommissioning design of spect fuel reprocessing plant《核燃料后处理厂退役设计安全准则》.pdf EJ T 1201-2006 Safety criteria for decommissioning design of spect fuel reprocessing plant《核燃料后处理厂退役设计安全准则》.pdf
  • EJ T 1203-2006 Requirements of radiation protection program for decommissioning operations of nuclear facilities《核设施退役实施中辐射防护大纲要求》.pdf EJ T 1203-2006 Requirements of radiation protection program for decommissioning operations of nuclear facilities《核设施退役实施中辐射防护大纲要求》.pdf
  • EJ T 1204 1-2006 Determination of the detection limit and decision threshold for ionizing radiation measurements Part 1 Counting measurements neglecting the influence of sample tre.pdf EJ T 1204 1-2006 Determination of the detection limit and decision threshold for ionizing radiation measurements Part 1 Counting measurements neglecting the influence of sample tre.pdf
  • EJ T 1204 2-2006 Determination of the detection limit and decision threshold for ionizing radiation measurements Part 2 Counting measurements with allowance for the influence of sa.pdf EJ T 1204 2-2006 Determination of the detection limit and decision threshold for ionizing radiation measurements Part 2 Counting measurements with allowance for the influence of sa.pdf
  • 相关搜索
    资源标签

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

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