有如下程序: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,
有如下程序: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(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++) 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,
相关考题:
有如下程序: include using namespace std; class Sample{ public: 有如下程序: #include<iostream> using namespace std; class Sample{ public: Sample()<) ~Sample(){cout<<'*';} }; int main(){ Sample temp[2],*pTemp[2]; return 0; } 执行这个程序输出星号(*)的个数为( )。A.1B.2C.3D.4
有如下程序: nclude using namespace std; class Stack{ 有如下程序: #nclude<iostremn> using namespace std; class Stack{ public: Stack(unsigned n=10:size(n){rep_=new int[size];top=O;} 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 opo(){--top;return rep_[top];} bool is Empty()const{return top==O;} pavate: 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,1B.4,3,6,7,2,1C.4,3,6,2,1D.1,2,3,4
有如下程序: include using namespace std; class Base { public: 有如下程序: #include <iostream> using namespace std; class Base { public: Base(int x=0) { cout<<x; } } class Derived: public Base{ public: Derived(int x=0) { cout<<x; } private: Base val; }; int main() { Derived d(1); return 0; }程序的输出结果是A.0B.1C.1D.1
有如下程序: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
以下程序的执行结果为______。include using namespace std; class base { public: vir 以下程序的执行结果为______。include<iostream>using namespace std;class base{public:virtual void who(){cout<<"base class"<<endl;}};class derivel:public base{public:void who(){cout<<"d
有如下程序: include using namespace std; class A { public: 有如下程序: #include<iostream> using namespace std; class A { public: A(){cout<<"A";} }; class B<public:B(){cout<<"B";)); class C:public A { B b; public: C(){cout<<"C";} }; int main(){Cobj;retum 0;} 执行后的输出结果是A.CBAB.BACC.ACBD.ABC
有如下程序: include using namespace std; class BASE { public 有如下程序: #include<iostream> using namespace std; class BASE { public: ~BASE(){cout<<"BASE";} }; class DERIVED:public BASE { public: ~DERIVED(){cout<<"DERIVED";} }; int main(){DERIVEDx;retum 0;} 执行后的输出结果是A.BASEB.DERIVEDC.BASEDERIVEDD.DERIVEDBASE
有以下程序:include using namespace std; class Base { public: Base() { K=0; } int 有以下程序:include<iostream>using namespace std;class Base{public:Base(){K=0;}int x;};class Derivedl:virtual public Base{public:Derivedl(){x=10;}};class Derived2:virtua1 public Base
有如下程序:include using namespace std;class Base{public:Base(){ cout 有如下程序: #include <iostream.h> using namespace std; class Base { public: Base(){ cout<<"BB"; f(); } voidf(){cout <<"Bf"; } }; class Derived: public Base { public: Derived (){cout<<"DD";} void f(){cout<<"Df";} }; int main(){Derived d; return 0;} 执行上面的程序将输出A.BBBfDDB.BBDfDDDfC.DDD.DDBBBf
有如下程序:include using namespace std;class BASE{public:~BASE(){cout 有如下程序: #include <iostream> using namespace std; class BASE{ public: ~BASE(){cout<<"BASE";} }; class DERIVED:public BASE{ public: ~DERIVED(){cout<<"DERIVED";} }; int main(){DERIVED x;return 0;} 执行后的输出结果是A.BASEB.DERIVEDC.BASEDERIVEDD.DERIVEDBASE
有如下程序: include using namespace std; class PARENT { public: PARENT() { cout 有如下程序:include <iostream>using namespace std;class PARENT{public:PARENT() { cout <<"PARENT"; }};class SON : public PARENT{public:SON() {cout << "SON"; }};int main(){SON son;PARENT *p;p = son;return 0;}执行上面程序的输出是______。
有如下程序: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,
有如下程序: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 x{protected: int a;public: x() {a= 有如下程序: #include <iostream> using namespace std; Class x { protected: int a; public: x() { a=1; } }; class x1 : virtual public x { public: x1() { a+=1; cout<<A.1B.123C.242D.244
有如下程序:include using namespace std;class AA{public: virtual void f() {cout 有如下程序: #include <iostream> using namespace std; class AA { public: virtual void f() { cout<< "AA"; } }; class BB : public AA { public: BB() { cout << "BB"; } }; claA.AAB.AABBCCC.BBAABBCCD.BBBBAACC
有以下程序:include include using namespace std;class base{private: cha 有以下程序: #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base ( ) { strcpy (baseName, "Base"); } virtual char *myName() {A.DerivedBaseB.BaseBaseC.DerivedDerivedD.BaseDerived
有如下程序: include using namespace std; class Sac{ int n; public: Sac():n(4){co 有如下程序:include<iostream>using namespace std;class Sac{int n;public:Sac():n(4){cout<<n;}Sac(int k):n(k){cout<<n;}~Sac(){cont<<n+n;}};int main(){Sac s1,*s2;s2=new Sac(3);delete s2;return 0;}运行时的输出结果是______。
有下列程序: include using namespace std; class Demo { public: Demo(){cout 有下列程序: #include<iostream.h> using namespace std; class Demo { public: Demo(){ cout<<"default constmctor\n";} Demo(const Demo x){ cont<<"copy constructor\n";} }; Demo userCode(Demo b){Demo c(b);return c;} intA.1和1B.1和2C.2和3D.2和4
有如下程序:include using namespace std;int s=0;class sample { static int n;publ 有如下程序: #include <iostream> using namespace std; int s=0; class sample { static int n; public: sample(int i) { n=i; } static void add() { s+=n; } };A.2B.5C.7D.3
有以下程序:includeusing namespace std;class BASE{private: char c;public: BASE(c 有以下程序: #include <iostream> using namespace std; class BASE { private: char c; public: BASE(char n):c(n);{} virtual~BASE() { cout<<c; } }; class DERIVED:public BASE { char c; pA.XYB.YXC.XD.Y
有如下程序:include using namespace std;class Base{private:charc;public:Base(cha 有如下程序:#include <iostream>using namespace std;class Base{private: char c;public: Base(char n) :c(n){} ~Base() { cout<<c; } };class Derived: public Base{private: char c; public: Derived(char n):Base(n+1),c(n) {} ~Derived() { cout<<c; }};int main (){ Derived obj ('x'); return 0;}执行上面的程序净输出A.xyB.yxC.xD.y
有下列程序: include using namespace std; class Base { public: Base(){cout 有下列程序: #include<iosteram.h> using namespace std; class Base { public: Base(){cout<<"BB"; f(); } void f(){cout<<"Bf";} }; class Derived:public Base { public: Derived(){cout<<"DA.BBBfDDB.BBDfDDDfC.DDD.DDBBBf
有下列程序: 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 A{public:A(){cout 有如下程序: #include <iostream> using namespace std; class A { public: A(){cout<<"A";} }; class B {public:B(){cout<<"B";} }; class C:public A { B b; public:C(){cout<<"C";} }; int main(){C obj;return 0;} 执行后的输出结果是( )。A.CBAB.BACC.ACBD.ABC
请在如下程序中的空格处填写正确的语句: include using namespace std; class Base { 请在如下程序中的空格处填写正确的语句:include <iostream>using namespace std;class Base {public:void fun() {cout<<"Base fun"<<endl; }};class Derived: public Base {public:void fun() {【 】; //调用基类的函数fun()cout<<"Derived fun "<<endl;}};