网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
下列程序的输出结果为()。includeclass TestClass{public:TestClass (){val++;}stat
下列程序的输出结果为( )。 #include<iostream.h> class TestClass { public: TestClass (){val++;} static int val; }; int TestClass::val=0; void main() { TestClass cs1; cout<<cs1.val<<""; TestClass cs2; TestClass cs3,cs4; cout<<cs2.val<<endl; }
A.03
B.13
C.14
D.24
参考答案
更多 “ 下列程序的输出结果为()。includeclass TestClass{public:TestClass (){val++;}stat 下列程序的输出结果为( )。 #include<iostream.h> class TestClass { public: TestClass (){val++;} static int val; }; int TestClass::val=0; void main() { TestClass cs1; cout<<cs1.val<<""; TestClass cs2; TestClass cs3,cs4; cout<<cs2.val<<endl; }A.03B.13C.14D.24 ” 相关考题
考题
有如下程序: 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 TestClass 1 { publi
以下程序输出结果为______。include<iostream>using namespace std;class TestClass 1{public:TestClass1(){}TestClass1(int i){x1=i;}void dispa(){cout<<"x1="<<x1<<",";}private:int x1;}:class TestClass2:public TestClass1{public:TestClass2(){}TestClass2(int i):TestClass1(i+10){x2=i:}void dispb(){dispa();cout<<"x2="<<x2<<end1;}private:int x2:}:int main(){TestClass2 b(2):b.dispb();return 0;}
考题
有如下程序:includeusing namespqce Std;class TestClass{private;Char C;public;Tes
有如下程序: #include<iostream> using namespqce Std; class TestClass { private; Char C; public; TestClass(char n):c(n){} ~TestClass() { cout<<c; }; class TestClassl:public TestClass { private: Char C; public:A.xyB.yxC.xD.y
考题
下列程序的输出结果为( )。 #include<iostream.h) class TestClass { public: TestClass(){val++;} static,int val; }; int TestClass::val=0; void main() { TestClass cs1; cout<<csl.val<<““; TestClass cs2; TestClass cs3,cs4; coA.03B.13C.14D.24
考题
若有如下程序:includeusing namespace std;class TestClass{public:void who(){cout
若有如下程序: #include<iostream> using namespace std; class TestClass { public: void who(){cout<<“TestClass”<<endl;} }; class TestClassl:public TestClass { public: void who(){cout<<“TestClassl”<<endl; int main() { TestCA.TestClasslB.TestClassC.0D.无输出
考题
有下列程序:include using namespace std; class TestClass1 { public: TestClass1(){
有下列程序:include<iostream>using namespace std;class TestClass1{public:TestClass1(){cout<<"A";}};class TestClass2<public:TestClass2(){cout<<"B";}};class TestClass3:public TestClass1{TestClass2 b;
考题
执行这个程序的输出结果是(); include using namespace std; class TestClass1 { publ
执行这个程序的输出结果是( );include<iostream>using namespace std;class TestClass1{public:void fun1(){cout<<"TestClass1\n";}virtual void fun2(){cout<<"TestClass1\n";}};class TestClass2:public TestClass1{public:void fun1(){cout<<"TestClass2\n";}void fun2(){cout<<"TestClass2\n";}};void f(TestClass1b){b.fun1();b.fun2();}int main(){TestClass2 obj;f(obj);return 0;}
考题
在下列的程序的横线处填上适当的语句,使该程序的输出为12。 includeusing namespace st
在下列的程序的横线处填上适当的语句,使该程序的输出为12。include<iostream>using namespace std;class TestClass{public:int a,b;TestClass(int i,int j){a=i;b=j;}};class TestClass1:public TestClass{int a;public:TestClass1(int x):TestClass(x,x+1){}void show(){______;//输出基类数据成员a的值?cout<<b<<endl;}};int main(){TestClass1 d(1);d.show();return 0;}
考题
下列程序的执行结果是( )。 include include Class TestClass
下列程序的执行结果是( )。 #include<iostream.h> #include<stdlib.h> Class TestClass { public: int x,y; TestClass(){x=y=0;} TestClass(int a,int b){x=a;y=b;} void disp() { cout<<"x="<<x<<",y="<<y<<end1; } }; void main() { TestClass s1(2,3); s1.disp(); }A.x=2,y=2B.x=3,y=3C.x=2,y=3D.x=3,y=2
考题
有如下程序:includeusing namespace std;class TestClass{private;char c;public;Tes
有如下程序: #include<iostream> using namespace std; class TestClass { private; char c; public; TestClass (char n):c(n){} ~TestClass () { cout<<c; } }; class TestClass1:public TestClass { Private: char c; public: TestClass1(char n):TestClass (n+1),c(n){} ~TestClass1() { cout<<c; } }; int main() { TestClass1 obj('x'); return 0; } 执行上面的程序输出( )。A.xyB.yxC.xD.y
考题
有如下程序:includeusing namespace std;class TestClass1{public:virtual void fun(
有如下程序: #include<iostream> using namespace std; class TestClass1 { public: virtual void fun(){cout<<"1";} }; class TestClass2: public TestClass1 { public: TestClass2(){cout<<"2";} }; class TestClass3:public TestClass2 { public: virtual void fun(){TestClass2::fun();cout<<"3";} }; int main() { TestClass 1 aa,*p; TestClass2 bb; TestClass3 cc; p=cc; P->fun(); return 0; } 执行上面程序的输出是( )。A.1122B.2112C.2213D.2223
考题
有如下程序:includeusing namespace std;class TestClass1{public:TestClass1 (){cou
有如下程序: #include<iostream> using namespace std; class TestClass1 { public: TestClass1 (){cout<<"TestClass1";} ~TestClass1 (){cout<<"~TestClass1";} }; class TestClass2:public TestClass1 { TestClass1 *p; public: Testclass2(){cout<<"TestClass2";p=new TestClass1();} ~TestClass2(){cout<<"~TestClass2";delete p;} ); int main() { TestClass2 obj; return 0; } 执行这个程序的输出结果是( )。A.TestClass2TestClass1TestClass1~TestClass1~TestClass2~TestClass1B.TestClass1TestClass2TestClass1~TestClass2~TestClass1~TestClass1C.TestClass2TestClass1TestClass1~TestClass2~TestClass1~TestClass1D.TestClass1TestClass2TestClas1~TestClass1~TestClass2~TestClass1
考题
有如下程序:includeincludeusing namespace std;class TestClass{public;T
有如下程序: #include<iostream> #include<iomanip> using namespace std; class TestClass{ public; TestClass (){cout<<'A';} TestClass(char C){cout<<c;) ~TestClass (){cout<<'B';} }; int main(){ TestClass p1,*p2; p2=new TestClass('X'); delete p2; return 0; } 执行这个程序的结果是( )。A.ABXB.ABXBC.AXBBD.AXB
考题
执行下列程序的输出结果是______: include using namespace std; class TestClass1 {
执行下列程序的输出结果是______:include<iostream>using namespace std;class TestClass1{public:void fun1(){cout<<"TestClass1\n";}virtual void fun2(){cout<<"TestClass1\n";}};class TestClass2:public TestClass1{public:void fun1(){cout<<"TestClass2\n";}void fun2(){cout<<"TestClass2\n";}};void f(TestClass1b)<b.fun1();b.fun2();}int main(){TestClass2 obj;f(obj);return 0;}
考题
下列程序输出结果为: include using namespace std; class TestClass1 { public: Test
下列程序输出结果为:include<iostream>using namespace std;class TestClass1{public:TestClass1(){}TestClass1(int i){x1=i;}void dispa(){cout<<"x1="<<x1<<",";}private:int x1;};class TestClass2:public TestClass1{public:TestClass2(){}TestClass2(int i):TestClass1(i+10){x2=i;}void dispb(){dispa();cout<<"x2="<<x2<<endl;}private:int x2;};int main(){TestClass2 b(2);b.dispb();return 0;}
考题
下列程序的执行结果是()。includeincludeclass TestClass{public:intx,y
下列程序的执行结果是( )。 #include<iostream.h> #include<stdlib.h> class TestClass { public: intx,y; TestClass(){x=y=0;} TestClass(int a,int b){x=a;y=b;} void disp() { cout<<"X"="<<X<<",y="<<y<<endl; }A.x=2,y=2B.x=3,y=3C.x=2,y=3D.x=3,y=2
考题
若有以下程序: include using namespace std; class TestClass 1 { public: TestClass
若有以下程序:include<iostream>using namespace std;class TestClass 1{public:TestClass1(){X=0;}int x;};class TestClass2:virtual public TestClass1{public:TestClass2(){x=10;}};class TestClass3:virtual public TestClass 1{public:TestClass3(){x=20;}};class TestClass4:public TestClass2, protected TestClass3{ };int main(){TestClass4 obj;cout<<obj.x<<end1;return 0:}该程序运行后的输出结果是______。
考题
下列程序的输出结果是( )。 include using namespace std; class TestClass
下列程序的输出结果是( )。 #include<iostream> using namespace std; class TestClass{ static int i; public: TestClass(){i++;} ~TestClass(){i--;} static int getVal(){return i;} }; int TestClass::i=O; void fun(){TestClass ob2;cout<<ob2.getVal();} int main(){ TestClass ob1; fun(); TestClass*ob3=new TestClass;cout<<ob3->getVal(); delete ob3;cout<<TestClass::getVal(); return 0; }A.111B.121C.211D.221
考题
有如下程序:includeusing namespace std;Class TestClass{int a;public:TestClass(in
有如下程序: #include<iostream> using namespace std; Class TestClass {int a; public: TestClass(int x){a=x;} void show(){cout<<a;}}; class TestClass1:public TestClass {int b; public: TestClass1(int i):TestClass(i+1),b(i){} voiA.5B.1C.0D.2
考题
下列程序的输出结果是()。 include using namespace std; class TestClass{ static in
下列程序的输出结果是( )。 #include<iostream> using namespace std; class TestClass{ static int i; public: TestClass(){i++;} ~TestClass(){i--;} static int getVal(){retum i;} }; int TestClass∷i=0; voiA.111B.121C.211D.221
考题
有下列程序:includeusing namespace std;class TestClass{protected:TestClass(){cou
有下列程序: #include<iostream> using namespace std; class TestClass{ protected: TestClass(){cout<<'x';} TestClass(char c){cout<<c;} }; class TestClassl:public TestClass{ public: TestClassl(char c){cout<<c;}A.yB.yxC.xyD.yy
考题
有下列程序:includeusing namespace std;class TestClass{int a;public:TestClass(in
有下列程序: #include<iostream> using namespace std; class TestClass { int a; public: TestClass(int x)<a=x;} void show(){cout<<a;} }; class TestClass1:publicTestClass { int b; public: TestClaA.5B.1C.0D.2
考题
若有如下程序:includeusing namespace std;class TestClass{public:void who() {cout
若有如下程序: #include<iostream> using namespace std; class TestClass { public: void who() {cout<<"TestClass"<<endl;} }; class TestClass1:public TestClass { public: void who(){cout<<"TestClass1"<<endl;} }; int main() { TestClass *p; TcstClass1 obj1; p=obj1; p->who(); return 0; } 则该程序运行后的输出结果是( )。A.TestClass1B.TestClassC.0D.无输出
考题
有如下程序: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
考题
若有以下程序:includeusing namespace std;class TestClass{public:void who(){cout
若有以下程序: #include<iostream> using namespace std; class TestClass { public: void who(){cout<<"TestClass"<<endl;} }; class TestClass1:public TestClass { public: void who(){cout<<"TestClass1"<<endl;} }; int main() { TestClass *p; TestClass1 obj1; P=obj1; P->who(); return 0; 则该程序运行后的输出结果是( )。A.TestClass1B.TestClassC.0D.无输出
考题
下列程序的输出结果为2,横线处应添加语句()。includeusing namespace std;{public:___
下列程序的输出结果为2,横线处应添加语句( )。 #include<iostream> using namespace std; { public: ______void fun(){cout<<1;} }; class TestClass2:public TestClass1 { public:void fun(){cout<<2;) }; int main() { TestClass1 *p=new TestClass2; p->fun(); delete p; Teturn 0; }A.publicB.privateC.virtualD.protected
考题
有如下程序: include using namespace std; class TestClass { int a
有如下程序: #include<iostream> using namespace std; class TestClass { int a; public: TestClass(int x){a=x;} void show(){cout<<a;} }; class TestClass1:public TestClass { int b; public: TestClass1(int i):TestClass(i+1),b(i){} void show(){cout<<b;} }; int main() { TestClass b(5),*p; TestClass1 d(1); p=d; p->show(); return 0; } 该程序运行后的打印结果是( )。A.5B.1C.0D.2
热门标签
最新试卷