C++ Logo
C++二级在线二级在线
首页选择题程序题成为会员帮助其他科目

选择题

49. 有如下程序: #include <iostream> 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(unsigned i=0;i<s.top;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(int i=1;i<3;i++)cout<<s2.pop()<<','; s2.push(6); s1.push(7); while(!s2.isEmpty())cout<<s2.pop()<<','; return 0; } 执行上面程序的输出是______。

上一题下一题