网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
有如下程序:includeusing namespace std;classStack{public:Stack (unsigned n=10)

有如下程序: #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,


参考答案

更多 “ 有如下程序:includeusing namespace std;classStack{public:Stack (unsigned n=10) 有如下程序: #include <iostream.h> using namespace std; class Stack { public: Stack (unsigned n=10):size (n) {rep_=new int [size]; top=0;} Stack (stacks}: 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, ” 相关考题
考题 重载操作符的定义一般见于 IEEE 库的哪几个程序包 A.std_logic_arith、std_logic_unsigned、std_logic_signedB.std_logic_arith、std_logic_unsigned、std_logic_1164C.std_logic_unsigned、std_logic_1164、std_logic_arithD.std_logic_1164、std_logic_arith、std_logic_unsigned、std_logic_signed

考题 有如下程序:includeusing namespace std;Class Base{public:Base(){cout 有如下程序: #include<iostream.h> using namespace std; Class Base { public: Base(){cout<<“BB”;f();} void{(){cout<<“BF”;} }; class Derived:public Base { public: Derived(){cout<<“DD”;} void f(){cout<<“Df”;) }; int mainA.BBBfDDB.BBDfDDDfC.DDD.DDBBBf

考题 有如下程序:includeUsing namespace std;Class Demo{public:Demo(){cout 有如下程序: #include<iostream.h> Using namespace std; Class Demo { public: Demo(){ cout<<“default constructor\n”;} Demo(const Demo x){ cont<<“copy constructor\n”;} }; Demo usercode(Demob){Demo c(b);return c;} int main() {A.1和1B.1和2C.2和3D.2和4

考题 以下程序实现栈的入栈和出栈的操作。其中有两个类:一个是节点类node,它包含点值和指向上一个节点的指针 prev;另一个类是栈类 stack, 它包含栈的头指针 top。生成的链式栈如下图所示。〈IMG nClick=over(this) title=放大 src="tp/jsj/2jc++j28.1.gif"〉下面是实现程序,请填空完成此程序。include 〈iostream〉using namespace std;class stack;class node{int data;node *prev;public:node(int d, node *n){data=d;prev=n;}friend class stack;};class stack{node *top; //栈头public:stack(){top=0;}void push(int i){node *n=【 】;top=n;}int pop(){node *t=top;if (top){top=top-〉prev;int c= t-〉data;delete t;return c;}return 0;}int main (){stack s;s.push(6);s.push(3);s.push (1);return 0;}

考题 有以下程序: include class A { intx; public: A(int a) { x=a;} friend class B; 有以下程序:include<iostream.h>class A{int x;public:A(int a){x=a;}friend class B;}class B{public:void print(A a){a. x--;cout<<a.x<<end1;}};void main(){A a(10);B b;b.print(a) ;}程序执行后的输出结果是【 】。

考题 有如下程序:includeincludeusing namespace std;class BASE{char c;public 有如下程序: #include<iostream>#include<iosream> using namespace std; class BASE{ char c; public; BASE(char n):c(n){} virtual ~ BASE(){cout<<c;} }; class DERIVED; public BASE{ char c; public: DERIVED (char n): BASE (n+1)A.XYB.YXC.XD.Y

考题 有下列程序: include using namespace std; class Stack { public: Stack(unsigned 有下列程序: #include<iosteram.h> using namespace std; class Stack { public: Stack(unsignedn=10):size(n){rep_=new int [size];top=O;} Stack(Stacks):size(s.size) { rep_=new int[size]; foA.4,3,2,1,B.4,3,6,7,2,1,C.4,3,6,2,1,D.1,2,3,4,

考题 有如下程序:include using namespace std;class Stack {public: Stack(unsigned n= 1 有如下程序: #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 ;i3;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,

考题 有如下程序:include using namespace std;class Stack{public:Stack(unsigned n=10 有如下程序: #include <iostream.h> using namespace std; class Stack { public: Stack(unsigned n=10):size(n){rep_=new int [size]; top=0;} Stack(Stacks): 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++) sl.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; } 执行上面程序将输出( )。A.4,3,2,1,B.4,3,6,7,2,1,C.4,3,6,2,1,D.1,2,3,4,