[计算机类试卷]国家二级(C++)机试模拟试卷74及答案与解析.doc
《[计算机类试卷]国家二级(C++)机试模拟试卷74及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级(C++)机试模拟试卷74及答案与解析.doc(31页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级( C+)机试模拟试卷 74及答案与解析 一、选择题 1 有如下程序: #include using namespace std; int main() void function(double val); double val; function(val); cout #include using namespace std; class Instrument public: Instrument(string t=“乐器 “,string n=“无名 “):type(t),name(n) virtual string GetType() const return “乐器 “; vi
2、rtual string GetName() const return “无名 “; protected: string type,name; ; class Piano:public Instrument public: Piano(string n,string t=“钢琴 “):Instrument(t,n) string GetType() const return “钢琴 “; string GetName() const return name; ; int main() Instrument *pi=new Piano(“星空 “); coutGetType()GetName()
3、; delete pi; return 0; 运行时的输出结果是 ( A)钢琴 -星空 ( B)钢琴 -无名 ( C)乐器 -星空 ( D)乐器 -无名 6 定义无符号整数类为 UInt,下面可以作为类 UInt实例化值的是 ( )。 ( A) 369 ( B) 369 ( C) 0.369 ( D)整数集合 1,2,3,4,5 7 下列关于运算符重载的叙述中,错误的是 ( A)可以通过运算符重载在 C+中创建新的运算符 ( B)赋值运算符只能重载为成员函数 ( C)运算符重载为类的成员函数时,第一操作数就是该类对象本身 ( D)重载类型转换运算符时不需要声明返回类型 8 有函数模板声明和一些
4、变量定义如下: template T1 sum(T2, T3); double d1,d2; 则下列调用中,错误的是 ( A) sum(d1,d2); ( B) sum(d1,d2); ( C) sum(d1,d2); ( D) sum(d1,d2); 9 若有定义语句 “doublea=2/3.0;“,则语句 cout using namesapce std; int return r; int main() int a=1,3,5,7; cout using namespace std; class Music public: void setTitle(char* str) strcpy
5、(title, str); protected: char type 10 ; private: char title 20 ; ; class Jazz : public Music public: void set(char* str) strcpy(type, “Jazz“); / strcpy(title, str); / ; 下列叙述中正确的是 ( )。 ( A)程序编译正确 ( B)程序编译时语句 出错 ( C)程序编译时语句 出错 ( D)程序编译时语句 和 都出错 22 已知枚举类型声明语句为: enum COLOR WHITE, YELLOW, GREEN=5, RED, B
6、LACK=10 ; 则下列说法中错误的是 ( )。 ( A)枚举常量 YELLOW的值为 1 ( B)枚举常量 RED的值为 6 ( C)枚举常量 BLACK的值为 10 ( D)枚 举常量 WHITE的值为 1 23 有如下类定义: class Cup public: Cup(double val,string cr=“red“):price(val),color(cr) / Cup(); / private: string color; / double price=5.8; / ; 在标注号码的语句行中存在语法错误的是 ( A) ( B) ( C) ( D) 24 软件按功能可以分为应用
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 模拟 74 答案 解析 DOC
