有如下程序: #includeiostream using namespace std; class AA{ int k; protected: int n; void setK(int k){this一k=k;} public: void setN(int n){this一n=n;} }; class BB:public AA{/*类体略*/}; int main } BB X; A n=1;//1 B setN(2);//2 C k=3;//3 D setK(4);//4 return 0; } 在标注号码的四条语句中正确的是( )。A.1B.2C.3D.4
有如下程序: #include<iostream> using namespace std; class AA{ int k; protected: int n; void setK(int k){this一>k=k;} public: void setN(int n){this一>n=n;} }; class BB:public AA{/*类体略*/}; int main } BB X; A n=1;//1 B setN(2);//2 C k=3;//3 D setK(4);//4 return 0; } 在标注号码的四条语句中正确的是( )。
A.1
B.2
C.3
D.4
相关考题:
有如下程序: include using namespace std; class TestClass{ int k; public: TestCla 有如下程序:include<iostream>using namespace std;class TestClass{int k;public:TestClass(int x=1):k(x){}~TestClass O{cout<<k;}};int main(){TestClass a[]={TestClass(3),TestClass(3),TestClass(3)};TestClass *p=new TestClass[2];delete []p;return ():}这个程序的输出结果是______。
有如下程序 include using namespace std; class Base { protected: 有如下程序 #include <iostream> using namespace std; class Base { protected: Base( ){cout<<'A'; } Base(char c) { cout<<c; } }; class Derived: public Base { public: Derived(char c){ cout<<c; } }; int main( ){ Derived d1 ('B'); return 0; } 执行这个程序屏幕上将显示输出A.BB.BAC.ABD.BB
有如下程序:includeusing namespace std;class XX{protected:int k;public:XX(int n= 有如下程序: #include<iostream> using namespace std; class XX { protected: int k; public: XX(int n=5):k(n){}; ~XX() { cout<<"XX": } virtual void f()const=0; }; inline void XX::f()const { cout<<k+3; }; class YY:public XX { public: ~YY() { cout<<”YY”; } void f()const { cout<<k-3; XX::f(); } }; int main() { XX p=*new YY; P.f(); delete p; return 0: } 执行上面的程序将输出( )。A.28XXB.28YYXXC.33XXD.33XXYY
有如下程序: #include<iostream) using namespace std; class AA{ int n; public: AA(int k):n(k){} int get(){return n;} int get()const{return n+1;} }; int main() { AA a(5); const AA b(6); COUt<<A.get()<<b.get(); return 0A.55B.57C.75D.77
有如下程序:includeusing namespace std;class DA{int k;public:DA(int x=1):k(x){}~ 有如下程序: #include<iostream> using namespace std; class DA{ int k; public: DA(int x=1):k(x){} ~DA(){cout<<k;} }; int main(){ DAd[]={DA(3),DA(3),DA(3)}; DA*p=new DA[2]; delete[]p; return(); } 这个程序的输出结果是( )。A.111B.333C.11333D.11133
有如下程序: include using namespace std; class AA { int n; 有如下程序: #include<iostream> using namespace std; class AA { int n; public: AA(int k);n(k){} intget(){return n;} int get()const{return n+1;} }; int main() { AA a(5); const AA b(6); cout<<a.get()<<b.get(); return 0; } 执行后的输出结果是A.55B.57C.75D.77
有如下程序:includeusing namespace std;class Base{protected:Base(){cout 有如下程序: #include<iostream> using namespace std; class Base{ protected: Base(){cout<<'Base';} Base(char c){cout<<c;} }; class Derived:public Base{ public: Derived(char c){cout<<c;} }; int main(){ Derived d('Derived'); return 0; } 执行这个程序屏幕上将显示输出( )。A.DerivedB.DerivedBaseC.BaseDerivedD.DerivedDerived
请将如下程序补充完整,使得输出结果为:bbaa include using namespace std; class A { 请将如下程序补充完整,使得输出结果为:bbaainclude <iostream>using namespace std;class A {public:【 】{cout << "aa"; }};class B: public A{public:~B(){ cout << "bb"; }};int main () {B *p= new B;delete p;return 0;}
有以下程序: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
有如下程序:#includeiostreamusing namespace std;class AA{public:AA(){tout‘l’;}};class BB:public AA{int k;public:BB():k(0){cout…2;}BB(int n):k(n){cout‘3’;}};int main(){BB b(4),C;return 0;}A.1312B.132C.32 D、1412
有如下程序:includeusing namespace std;class XX{protected;int k;public:XX(int n= 有如下程序: #include<iostream> using namespace std; class XX{ protected; int k; public: XX(int n=5):k(n){} ~XX(){cout<<"XX";} Virtual void f()cons=0; }; inline void XX::f()const{cout<<k+3;} class YY:public XX{ public:A.28XXB.28YYXXC.-33XXD.-33XXYY
下面程序的输出结果是【】。 include using namespace std; class A {int a,b; public:A 下面程序的输出结果是【 】。include <iostream>using namespace std;class A{int a, b;public:A(){a = b = 0;}A(int aa, int bb ) : a(aA) , b(bB){cout <<"a="<<a<<","<<"b="<<b<<",";}~A(){cout<<"D";};int main ( ){A x, y(2, 3);return 0;}
有如下程序:include using namespace std;class AA {int n;public:AA(int k):n(k) {} 有如下程序:#include <iostream>using namespace std;class AA { int n;public: AA(int k):n(k) {} int get(){return n;} int get()const { return n+1; }};int main(){ AAa(5); const AA b(6); cout<<a. get()<<b. get(); return ();}执行后的输出结果是( )。A.55B.57C.75D.77
有如下程序: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 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;}运行时的输出结果是______。
有如下程序:includeusing namespace std;class AA{ int n;public: AA(int k):n (k){} 有如下程序: #include<iostream> using namespace std; class AA{ int n; public: AA(int k):n (k){} int get(){return n;) int get()const{return n+1;} }; int main() { AA a(5); const AA b(6); cout<<a.get()<<b.get(); return 0; } 执行后的输出结果是A.55B.57C.75D.77
有如下程序: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 DA {int k;public:DA(int x=1):k (x){ 有如下程序; #include<iostream> using namespace std; class DA { int k; public: DA(int x=1):k (x){} ~DA( ){cout<<k;} }; int main( ){ DA d[]={DA(3),DA(3),DA(3)}; DA *p=new DA[2]; delete []p; return (); } 这个程序的输出结果是( )。A.111B.333C.11333D.11133
有如下程序: inClude using namespace std; class AA { public: viltual void f() { c 有如下程序:inClude<iostream>using namespace std;class AA{public:viltual void f(){cout<<"AA";}};class BB:public AA{public:BB(){cout<<"BB";}};class CC:public BB{public:virtual void f(){BB::f();cout<<"CC";}};int main(){AA aa,*p;BB bb;CC cc;p=cc;p->f();return 0;}运行后的输出结果【 】。
有如下程序:includeusing namespaee std;class AA{public:AA( ){cout 有如下程序: #include<iostreanl> using namespaee std; class AA{ public: AA( ){cout<<'1';} }; class BB:public AA{ int k; public: BB( ):k(0){eout<<'2';} BB(int n):k(n){cout<<'3';} }; int main( ){ BB,b(4),c; return 0; } 程序的输出结果是A.1312B.132C.32D.1412
有如下程序:includeusing namespace std;class TestClass{protected:TestClass(){co 有如下程序: #include<iost earn> using namespace std; class TestClass{ protected: TestClass(){cout<<'x';} TestClass(char C) {cout<<c;} }; class TestClass1:public TestClass { public: TestClass1(char C) {Cout<<c;) }; int main(){ TestClass1 d1('y'); return 0; } 执行这个程序,屏幕上将显示输出( )。A.yB.yxC.xyD.yy
有如下程序:include using namespace std;class AA{ int n;public: AA(int k):n (k) 有如下程序: #include <iostream> using namespace std; class AA{ int n; public: AA(int k):n (k) { } int get(){return n; } int get()const{return n+1;} } int main() { AA a(5); const AA b(6); cout<<a.get()<<b.get(); return 0; } 执行后的输出结果是( )。A.55B.57C.75D.77
有如下程序:includeusingnamespacestd;classXX{protected: intk;public: XX(intn=5): 有如下程序: #include <iostream> using namespace std; class XX { protected: int k; public: XX(int n=5):k(n){} ~XX() { cout<<"XX"; } virtual void f() const=0; }; inline void XX::f()A.28XXB.28YYXXC.-33XXD.-33XXYY
若有以下程序:include using namespace std;class Base{private: int x;protected: i 若有以下程序: #include <iostream> using namespace std; class Base { private: int x; protected: int y; public: int z; void setx(int i) { x=i; int getx () { return x; } }A.1,2,3,4B.产生语法错误C.4,3,2,1D.2,3,4,5
有如下程序:include using namespace std;class Base{ protected: int i;public: int 有如下程序: #include <iostream> using namespace std; class Base { protected: int i; public: int j; }; class Derived:public Base {int m; public: int n; }; int main() { Derived d; d.i=0;//[1]d.j=0;//[2]d.m=0;//[3]d.n=0;//[4]return 0; } 其中主函数中有两个赋值语句有错,这两个错误的赋值语句是______ 。A.[1]和[2]B.[1]和[3]C.[2]和[3]D.[2]和[4)
有如下程序:include using namespace std;class shapes{protected: int x, y;public: 有如下程序: #include <iostream> using namespace std; class shapes { protected: int x, y; public: void setvalue(int d, int w=O) { x=d; y=w; } virtual void disp()=O; }; class square : public shapes { public: void disp () { cout<<x*y<<end1; } }; int main ( ) { shapes *ptr; square s1; ptr=s1; ptr->setvalue (10, 5) ;ptr->disp(); return 0; } 执行上面的程序将输出( )。A.50B.5C.10D.15