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

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

1、国家二级( C+)机试模拟试卷 113及答案与解析 一、选择题 1 下列叙述中正确的是 ( )。 ( A)循环队列有队头和队尾两个指针,因此,循环队列是非线性结构 ( B)在循环队列中,只需要队头指针就能反映队列中元素的动态变化情况 ( C)在循环队列中,只需要队尾指针就能反映队列中元素的动态变化情况 ( D)循环队列中元素的个数是由队头指针和队尾指针共同决定 2 下列有关函数重载的叙述中,错误的是 ( )。 ( A)函数重载就是用相同的函数名定义多个函数 ( B)重载函数的参数列表必须不同 ( C)重载函数的返回值类型必须不同 ( D)重载函数的参数可以带有默认值 3 有如下程序: #inc

2、lude using namespace std; class MyClass public: MyClass() +count; MyClass() -count; static int getCount() return count; private: static int count; ; int MyClass:count=0; int main() MyClass obj; cout using namespace std; class TV public: TV(int s=41):size(s) void Print() cout using namespace std; voi

3、d f1(int x=y; y=z; void f2(int x, int y) int z=x+y; x=y; y=z; int main() int x=10,y=26; f1(x,y); f2(x,y); coutclassA; ( B) templateclassA; ( C) templateclassA; ( D) templateclassA; 13 下列选项中,正确的 C+标识符是 ( A) a3 ( B) a-3 ( C) a3 ( D) a_3 14 对于一个类定义,编译器可能会自动生成的函数不包括 ( A)复制构造函数 ( B)缺省的构造函数 ( C)析构函数 ( D)友

4、元函数 15 当使用 ifstream流类定义一个流对象并打开一个磁盘文件时,文件的默认打开方式为 ( )。 ( A) ios_base:in ( B) ios_base:in|ios_base:out ( C) ios_base:out ( D) ios_base:in ( B) templateTfun(Tx,intn)returnx+n; ( C) templateTfun(T*p)return*p; ( D) templateTfun()returnT; 18 某个工厂有若干个仓库,每个仓库存放有不同的零件,相同零件可能放在不同的仓库中。则实体仓库和零件间的联系是 ( A)多对多 (

5、B)一对多 ( C)多对一 ( D)一对一 19 关于类定义,下列叙述中错误的是 ( A)如果没有定义复制构造函数,编译 器将生成一个复制构造函数 ( B)如果没有定义复制构造函数,编译器将生成一个复制构造函数 ( C)如果没有定义构造函数,编译器将生成一个默认的构造函数和一个复制构造函数 ( D)如果已经定义了构造函数和复制构造函数,编译器不会生成任何构造函数 20 支持子程序调用的数据结构是 ( )。 ( A)栈 ( B)树 ( C)队列 ( D)二叉树 21 下列关于函数的描述中,错误的是 ( )。 ( A)函数可以没有返回值 ( B)函数可以没有参数 ( C)函数可以是一个类的成员 (

6、 D)函数不能被定义 为模板 22 有如下程序: #include using namespace std; class AA int k; protected: int n; void setK(int k) this-k=k; public: void setN(int n) this-n=n; ; class BB: public AA /*类体略 */ ; int main() BB x; x.n=1; /1 x.setN(2); /2 x.k=3; /3 x.setK(4); /4 return 0; 在标注号码的四条语句中正确的是 ( )。 ( A) 1 ( B) 2 ( C) 3

7、 ( D) 4 23 有如下程序段: int i=2;int j=3; int main() int i=9, j=i; cout using namespace std; class Book public: Book(char* t=“ “) strcpy(title,t); private: char title 40 ; ; class Novel : public Book public: Novel(char* t=“ “): Book(t) char* Category()const return “文学 “; ; int main() Book *pb; pb=new Nove

8、l(); coutCategory(); delete pb; return 0; 若程序运行时输出结果是 “文学 “,则横线处缺失的语句是 ( )。 ( A) char*Category(); ( B) char*Category()const; ( C) virtualchar*Category()const; ( D) virtualchar*Category()const=0; 35 执行下列语句段后,输出字符 “*“的个数是 ( )。 for(inti=50;i1;i-=2) cout using namespace std; class AA public: AA() cout u

9、singnamespacestd; clasSDoor inthum;门号 boolclosed; true表示门关着 boollocked; true表示门锁着 public: ERROR*found* Door(intn): num(n), closed(true), lock(true) boolisClosed()constreturn closed; 门关着时返回 true,否则返回 false boolisOpened()constreturn! closed; 门开着时返回 true,否则返回 false boolisLocked()constreturn locked; 门锁着

10、时返回 true,否则返回 false boolisUnlocked()COnStreturn! locked; 门未锁时返回 true,否则返回 false ERROR*found* voidopen()const开门 cout usingnamespacestd; constintNAXNUH=100; classBag private: inthum; intbagNAXNUH; public: Bag(intm, intn=0);构造函数 booloperator=(Bag b);重载运算符 = intTnBag(int: ball);某一小球在袋子内的出现次数,返回 0表示不存在 ;

11、 Bag: Bag(intm, intn) if(rlHg_XNUH) cerEn; for(i=0; idatai; Bagb1(data, n);创建袋子对象 b1 cinn; for(i=0; idatai, Bagb2(data, n);创建袋子对象 b2if(b1=b2)测试 b1和 b2是否相同 cout #incllude usingnamespacestcl; template classArray数组类 public: Array(Typeb, intmm): size(mm) 构造函数 if(size=size)cout voidArray: MinTwo(Type。 四、综合应用题 43 【正确答案】 for (int i = 2; i ai) if (x1 ai) x2 = x1;

展开阅读全文
相关资源
猜你喜欢
相关搜索

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

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