black

登录

未知题型

有如下程序: #include <iostream.h> using namespace std; class Stack { public: Stack (unsigned n=10):size (n) {rep_=new int [size]; top=0;} Stack (stack&s}: size (s.size) { rep_new int[size]; for (int i=0;i<size;i++ rip_[i]-s.rep_[i]; top=s.top; } ~Stack() {delete[]rep_;} void poush (int a) {rep_[topj=a; top++;} int pep() { --top; return rep_[top];} bool isEmpty() cons5 [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); s1.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,

A.h>
B.size)
C.rep_[i];
D.top;
E.push(i);
F.pop()<<',';
G.push(6);
H.push(7);
I.isEmpty())
J.pop()<<',';
K.4,3,2,1,
B.4,3,6,7,2,1,
C.4,3,6,2,1,
【参考答案】

C
解析:本题是一个综合应用考题,考核知识点包括类与对象的应用(包括构造函数、拷贝构造函数),循环语句的使用、指......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)

相关考题

未知题型 在窗体上添加一个名称为Command1的命令按钮,然后编写如下事件代码: Private Sub Command1_Click( ) Dim a(10,10) For m=2 To 4 For n=4 TO 5 a(m,n)m*n Next n Next m MsgBox a(2,4)+a(3,5)+a(4,5) End Sub 打开窗体运行后,单击命令按钮,则消息框的输出结果是( )。D.53

单项选择题 铝合金等非铁金属常以析出金属间化合物之方式达成强化。但若析出的处理时间过长, 其硬度反而会逐渐降低,此为何种现象? ( ) A. 固溶处理 B. 过时效 C. 热膨胀 D. 欠时效

未知题型 What is the author's attitude to the topic?D.Sympathetic:

All Rights Reserved 版权所有©考试题库网(kstiku.com)

备案号:湘ICP备14005140号-3

经营许可证号:湘B2-20140064