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

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

1、国家二级 C机试(选择题)模拟试卷 115及答案与解析 一、选择题 1 有如下程序: #include #include using namesplace std; int main() coutopen(“file dat“); 8 当使用 ifstream流类定义一个流对象并打开一个磁盘文件时,文件的默认打开方式为 ( )。 ( A) ios_base in ( B) ios_base in ios_base out ( C) ios_base out ( D) ios_base in ios_base out 9 在下列枚举符号中,用来表示 “相对于当前位置 ”文件定位方式的是 ( )。

2、 ( A) ios_base cur ( B) ios_base beg ( C) ios_base out ( D) ios_base end 10 打开文件时可单独或组合使用下列文件打开模式 ( )。 ios_base app ios_base binary ios_base in ios_base out 若要以二进制读方式打开一个文件,需使用的文件打开模式为 ( A) ( B) ( C) ( D) 11 下列关于文件流的描述中,正确的是 ( )。 ( A)文件流只能完成针对磁盘文件的输入和输出 ( B)建立一个文件流对象时,必须同时打开一个文件 ( C)若输入流要打开的文件不存在,将建

3、立一个新文件 ( D)若输出流要打开的文件不存在,将建立一个新文件 12 若目 前 D盘根目录下并不存在 test txt文件,则下列打开文件方式不会自动创建 test txt文件的是 ( )。 ( A) ifstream fin; fin open(“d: test txt“, ios_base in); ( B) fstream rio; fio open(“d: test txt“, ios_base out); ( C) ofstream fout; fout open(“d: test txt“, ios_base out); ( D) ofstream fout; fout ope

4、n(“d: test txt“, ios_base app); 13 如需要向一个二进制文件尾部添加数据,则该文件的打开方式为 ( )。 ( A) ios_base app ( B) ios_base binary ios_base out ( C) ios_base out ( D) ios_base binary ios_base app 14 有如下语句序列: ifstream infile(“DATA DAT“); if(infile good()eout class BigNumber long n; public: BigNumber(T i): n(i) BigNumber op

5、erator (BigNumber b) return BigNumber(n b n); 已知 b1、 b2是 BigNumber的两个对象,则下列表达式中错误的是 ( )。 ( A) b1 b2 ( B) b1 3 ( C) 3 b1 ( D) 3 3 20 为类 Matrix重载下列运算符时,只能作为 Matrix类成员函数重载的运算符是( )。 ( A) ( B) ( C) ,使得程序中可以 “cinobj; ”形式输入MyClass 类的对象 obj,则横线处的声明语句应为 ( )。 ( A) friend istream&operator(istream&is, MyClass&a

6、); ( B) friend istream&operator(istream&is, MyClass a); ( C) istream&operator(istream&is, MyClass&a); ( D) istream&operator(istream&is, MyClass a); 22 若为 Fraction类重载前增 1运算符,应在类体中将其声明为 ( )。 ( A) Fraction&operator (); ( B) Fraction&operator (int); ( C) Mend Fraction&operator (); ( D) friend Fraction&o

7、perator (int); 23 若需要为 XV类重载乘法运算符,运算结果为 XV类型,在将其声明为类的成员函数时,下列原型声明正确的是 ( )。 ( A) XV operator*(XV,XV); ( B) XV*(XV); ( C) operator*(XV); ( D) XV operator*(XV); 24 已知类 MyClock中未显式定义构造函数,并重载了加法运算符,使得下面的语句序列能够正确执行: MyClock c1, c2; / c2 c1 10; 由此可知:为类 MyClock重载的 “ ”运算符函数的声明是 ( )。 ( A) friend MyClock opera

8、tor (MyClock, int); ( B) friend MyClock operator (MyClock, MyClock); ( C) friend MyClock operator (int, MyClock); ( D) MyClock operator (MyClock); 25 已知将运 算符 “ ”和 “*”作为类 Complex的成员函数重载,设 c1和 c2是类Complex的对象,则表达式 c1 c2*c1等价于 ( )。 ( A) c1 operator*(c2 operator (c1) ( B) c1 operator (c2 operator*(c1) (

9、C) c1 operator*(c1 operator (c2) ( D) c2 operator (c1 operator*(c1) 26 下列运算符不能重载为友元函数的是 ( )。 ( A) () ( B) - ( C) ( D) * 27 若要重载、 型, int型不能和别的型做运算。 【知识模块】 运算符重载 20 【正确答案】 B 【试题解析】 在 C中,、 、 ()、以及所有的类型转换运算符只能作为成员函数重载。 【知识模 块】 运算符重载 21 【正确答案】 A 【试题解析】 C的输入运算符 作为非类成员函数重载。在一个类中,可将输入运算符 声明为友元函数,在类 MyClass重

10、载输入运算符 的形式如选项 A所示。 【知识模块】 运算符重载 22 【正确答案】 A 【试题解析】 在类 Fraction中重载前增 1运算符时,其声明形式为 Fraction &operator ();在类 Fraction中重载后增 1运算符时,其声明形式为Fraction &operatorH(int);。 【知识模块】 运算符重载 23 【正确答案】 D 【试题解析】 “*”是一个二元运算符,在作为成员函数重载时参数中只有一个参数,对应于第二个操作数,而第一个操作数就是对象本身,仅以 this指针的形式隐藏在参数表中。 【知识模块】 运算符重载 24 【正确答案】 A 【试题解析】

11、由表达式 c2 c1 10可知,在对 “ ”进行重载时,第一操作数是MyClock类的对象,而第二操作数是一个整型数据。 【知识模块】 运算符重载 25 【正确答案】 B 【试题解析】 表达 式 c1 c2*c1的含义是 c1加上 c2与 c1的积。 【知识模块】 运算符重载 26 【正确答案】 A 【试题解析】 此题考查的是运算符重载的概念。 C抖语言规定, =、 、 ()、 -以及所有的类型转换运算符只能作为成员函数重载,如果要重载为友元函数就必须重载为非成员函数。 【知识模块】 运算符重载 27 【正确答案】 D 【试题解析】 、 、 ()、 以及所有的类型转换运算符只能作为成员函数重载,而且不能是针对枚举类型操作数的重载。 【知识模块】 运算符重载 28 【正确答案】 C 【试题解析】 赋值运算符只能作为类的成员函数重载。 【知识模块】 运算符重载

展开阅读全文
相关资源
猜你喜欢
  • BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf
  • BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf
  • BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf
  • BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf
  • BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf
  • BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf
  • BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf
  • BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf
  • BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf
  • 相关搜索

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

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