首页/ 题库 / [单选题]下面程序输出的结果为( )。 #incl的答案

下面程序输出的结果为( )。 #include"iostream.h" classA {public: A(){cOUt<<"CLASSA"<<endl;} ~A(){}}; ClaSSB:publicA {public: B(){cout<<"CLASSB"<<endl;} ~B(){}}; voidmain() {A*P; P=newB: B*q: q=newB;}

单选题
2022-01-09 15:49
A、CLASSA
B、CLASSA CLASSBCLASSB CLASSB
C、CLASSA
D、CLASSA CLASSBCLASSB CLASSACLASSB CLASSBCLASSB
查看答案

正确答案
C

试题解析
C。【解析】本题考查类的继承、类的实例化和构造函数、析构函数的调用方式以及何时调用。每实例化一个类就要调用其构造函数,结束运行该实例后调用析构函数。

标签:
感兴趣题目
下面程序的结果是( )。 #include<iostream.h> class A { int a; public: A():a(1){} void showa(){cout<<a;} }; Class B { int a; public: B():a(2){} void showa(){cout<<a;} ); class C:public A,public B { int a; pu
下列程序的输出结果是( )。 #include<iostream.h> void main() { char*Str; str="testI"; cout<<str[5]; }
以下程序的输出结果是 #include<iostream.h> void main( ) { int a=21,b=11; cout<<- -a+b;}
以下程序的输出结果是 #include<iostream.h> void main( ) { char x=040; cout < < (X < < 1) ;}
以下程序的输出结果是 #include<iostream.h> void main() { char x=040; cout<<(x<<1);}
下面程序的运行结果是 #include<iostream.h> class base{ protected: int a; public: base( ){cout<<"0";} }; class basel:virtual base { public: base1( ){cout<<"1";} }; class base2:virtual base{ public:
下面程序的运行结果是( )。 #include<iostream.h> class base{ protected: int a; public: base(){cout<<“0”;} }; Class basel:Virtual base{ public: basel(){cout<<“1”;} }; Class base2:virtual base{ public: base2(){cout<<“2”;)
下面程序输出的结果为 #include"iostream.h” class A { public: A(){cout<<"CLASSA"<<endl;} ~A() {} }; class B:public A { public: B(){cout<<"CLASS B"<<endl;} ~B(){} }; void main() { A*p; p=new B;
下面程序输出的结果为( )。 #inClUde”iostream.h” Class A {public: A(){cout<<“CLASS A”<<endl;} ~A()<)}; class B:public A {public: B(){cout<<”CLASSB”<<endl;} ~B(){}}; void main() {A*p; p=new B; B *q; q=new B;}
有如下程序: #include<iostream> using namespace std; classA { 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;} 执行后的输出结果是( )
下面程序的结果是 #include<iostream.h> class A { int a; public: A( ):a(1){} void showa( ){cout<<a;} }; class B { int a; public: B( ) :a(2) {}
下面程序输出的结果为 #include"iostream.h" class A { public: A(){cout<<"CLASSA"<<endl;} ~A() {} }; class B:public A { public: B(){cout<<"CLASSB"<<endl;} ~B() {} }; void main() { A * p; p=new B; B *q; q=new B; }
相关题目
下面程序的结果是( )。 #include<iostream.h> class A { int a; public: A():a(1){} void showa(){cout<<a;} }; Class B { int a; public: B():a(2){} void showa(){cout<<a;} ); class C:public A,public B { int a; pu
下面程序的运行结果为 #include<iostream.h> class A { public: A( ){cout<<"1";} ~A( ){cout<<"2";} }; class B:public A { public: B( ){cout<"3";} ~B( ){cout<<"4";} }; void main( ) { B
下面程序的运行结果为 #include<iostream,h> class A { public: A(){cout<<"1";} ~A(){cout<<"2";} }; Class B:public A { public: B(){cout<<"3";} ~B(){cout<<"4";} }; void main() { B b; }
下面程序的结果是 #include<iostream.h> class A { public: A(){cout<<"construtA" <<endl;} virtual ~A() {cout << "destructA" <<endl;}}; class B:public A { }; class C:public A { }; class D:public B,public C { }; void main() { Dd;}
下面程序的输出结果是 #include<iostream,h> class example { int a; public: example(int b) {a=b++;} void print( ){a=a+1;cout<<a<<"";} void print( )const{cout<<a<<"";} }; void main( ) { example X(3);
下面程序的结果是 #include<iostream.h> class A { public: A(){cout<<"construtA" <<endl;} virtual ~A() {cout << "destructA" <<endl;}}; class B:public A { }; class C:public A { }; class D:public B,public C { }; void main() { Dd;}
下面程序的运行结果为 #include<iostream.h> class A { public: A( ){cout<<"1";} ~A( ){cout<<"2";} }; class B:public A { public: B( ){cout<"3";} ~B( ){cout<<"4";} }; void main( ) { B
下面程序的运行结果为 #include<iostream,h> class A { public: A(){cout<<"1";} ~A(){cout<<"2";} }; Class B:public A { public: B(){cout<<"3";} ~B(){cout<<"4";} }; void main() { B b; }
下面程序的输出结果是( )。 #include<iostream.h> #include"string.h" void main() {char a[]="Hello Test",b[]="Test"; strcpy(a,b); cout<<a<<end1; } A) B)C) D)
下列程序的输出结果是( )。 #include<iostream.h> #include"string.h" void main() {char a[]="Hello Test",b[]="Test"; strcpy(a,b); cout<<a<<end1; }
下列程序的输出结果为 #include<iostream.h> void main( ) { char * a[ ]={"hello","the","world"}; char * * pa=a; pa++; cout <<*pa<<end1; }
下列程序的输出结果为 #include<iostream.h> void main() { char*a[]={"hello","the","world"}; char**pa=a; pa++; cout<<*pa<<end1; }
下面程序的结果是 #include"iostream.h" void main( ) { char * str; str="test!"; cout<<str[5]; }
下面程序的结果是 #include" iostream.h" void main( ) { char * str; Str="test!"; cout < < str[5]; }
下面程序输出的结果为( )。 #include"iostream.h" classA {public: A(){cOUt<<"CLASSA"<<endl;} ~A(){}}; ClaSSB:publicA {public: B(){cout<<"CLASSB"<<endl;} ~B(){}}; voidmain() {A*P; P=newB: B*q: q=newB;}
下列程序执行结果是( )。 #include(iostream.h) classA {public: inta; A( ):a(10){cout<<a<<endl;) }; voidmain( ) {Aobj1; Aobj2(obj1); cout<<""<<obj2.a<<endl; }
下面程序的运行结果为( )。 #include<iostream.h> class A { public: A{tout<<”1”;} ~A{tout<<”2”;} }; class B:public A { public: B{cout<<”3”;} ~B{cout<<”4”;} }; void main { B b; }
下面程序的运行结果为( )。 #include<iostream.h> ClassA { public:A( ){cout<<"1";} ~A( ){cout<<"2";} }; ClassB:public:A { public: B( ){cout<<"3";} ~B( ){cout<<"4";} }; Voidmain( ) { Bb; }
下面程序的结果为 #include<iostream.h> int c; class A { private: int a; static int b; public: A( ) {a=0;c=0;} void seta( ){a++;} void setb( ){b++;}
下面程序的结果是 #include<iostream.h> class A { public: A( ) {cout<<"construtA"<<endl;} virtual~A( ) {cout<<"destructA"<<endl;}}; class B:public A {}; class C:public A {}; c
广告位招租WX:84302438

免费的网站请分享给朋友吧