TOP

2010计算机等级考试二级(C++)笔试125(四)
2011-01-15 09:59:54 来源: 作者:[标签:作者] 【 】 浏览:810次 评论:0
微信搜索关注"91考试网"公众号,领30元,获取公务员、事业编、教师等考试资料40G!
内容。

----------------------------------------

33、关于关键字class 和typename,下列表述正确的是______ 。

A.程序中所有的tyeame都可以替换为cla

B.程序中所有的cla都可以替换为tyeame

C.A)和B)都正确

D.A)和B)都不正确

参考答案: A

typename的相关内容。

----------------------------------------

34、 有如下程序: #include <iostream> #include <iomanip> using namespace std; class CSum {int x,y; public: CSum(int x0,int y0):x(x0),y(y0) {} friend ostream& operator<<(ostream & os, const CSum& xa) { os<<setw(5)<<xa.x+xa.y; return os; } int main() { CSum y(3,5); cout<<setfill(''''*'''')<<8; cout<<y; return 0; } 执行上面程序的输出是______。

A.88

B.****88

C.****8****8

D.8****8

参考答案: D

setw 设置输出宽度。

----------------------------------------

35、 有如下程序: #include <iostream> using namespace std; class Stack { public: Stack(unsigned n= 10):size(n) {rep_=ew int[size]; top=0;} Stack(Stack& s):size(s.size) { rep_=new int[size]; for(int i=0;i<size;i++) rep_[i]=s.rep_[i]; top=s.top; } ~Stack() {delete []rep_;} void push(int a) {rep_[top]=a; top++;} int pop() {--top;return rep_[top];} bool isEmpty() const {return top==0;} private: int *rep_; unsigned size,top; }; int main() { Stack s1; for(int i= 1;i<5 ;i++) s1. push(i); Stack s2(s1); for(i= 1 ;i<3;i++) cout<<s2.pop()<<'''',''''; s2.push(6); si.push(7); while(!s2.isEmpty()) cout<<s2.pop()<<'''',''''; return 0; } 执行上面程序的输出是______ 。

A.4,3,2,1,

B.4,3,6,7,2,1,

C.4,3,6,2,1,

D.1,2,3,4,

参考答案: C

栈是“先进后出”的数据结构。
Tags:计算机二级考试试题 计算机二级考试真题 责任编辑:w48225117
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇2010计算机等级考试二级(C++)笔.. 下一篇2010计算机等级考试二级(C++)笔..

相关栏目

最新文章

推荐文章

网站客服QQ: 960335752 - 14613519 - 48225117