niusouti.com

下面程序输出的结果是( )。 include using namespace std; class A{下面程序输出的结果是( )。 #include<iostream> using namespace std; class A{ int X; public: A(int x):x(++x){} ~A(){cout<<x;} }; class B:public A{ int y; public: B(int y):A(y),y(y){} ~B(){cout<<y;}; }; void main(){ B

题目
下面程序输出的结果是( )。 include using namespace std; class A{

下面程序输出的结果是( )。 #include<iostream> using namespace std; class A{ int X; public: A(int x):x(++x){} ~A(){cout<<x;} }; class B:public A{ int y; public: B(int y):A(y),y(y){} ~B(){cout<<y;}; }; void main(){ B b(3); }

A.34

B.43

C.33

D.44


相似考题
更多“下面程序输出的结果是( )。 #include<iostream> using namespace std; class A{ ”相关问题
  • 第1题:

    如下程序的输出结果是includevoid fun(int & X,inty){intt=x;x=y;y=t;}int main(){in

    如下程序的输出结果是 #include<iostream> void fun(int & X,inty){intt=x;x=y;y=t;} int main( ){ int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; }

    A.42,42

    B.23,23

    C.23,42

    D.42,23


    正确答案:B
    解析:参数X是引用传递,传递的是地址:参数Y是值传递,函数fun( )是做X与Y值交换,交换后X的值要被回传给a[1],此时a[1]=a[0]=23。

  • 第2题:

    下面程序输出的结果是()。includeusing namespace std;void main(){ char ch[][8]={"g

    下面程序输出的结果是( )。 #include<iostream> using namespace std; void main() { char ch[][8]={"good","better","best"}; for(int i=1;i<3;++i) { cout<<ch[i]<<endl; } }

    A.good better

    B.better best

    C.good best

    D.good


    正确答案:B
    解析:二维数组ch共3行8列,for循环语句输出第2、3行的数组元素

  • 第3题:

    下面程序的输出结果是()。include using namespace std;class A {public:A( ) {cout<<

    下面程序的输出结果是( )。 #include <iostream> using namespace std; class A { public: A( ) {cout<<"A";} } class B { public: B() {coat<<"B" ;} } class C: public A { public: B b; C() {cout<<"C";} } void mian(){ C c; }

    A.CBA

    B.ABC

    C.ACB

    D.BCA


    正确答案:B
    解析:先执行基类A构造函数输出A,调用类B的构造函数输出B,调用本身构造函数输出C。

  • 第4题:

    下面程序的输出结果是()。includeinclude"string.h"void main(){char a[]="Hello T

    下面程序的输出结果是( )。 #include<iostream.h> #include"string.h" void main() {char a[]="Hello Test",b[]="Test"; strcpy(a,b); cout<<a<<end1; } A) B)

    C) D)

    A.Hello

    B.Test

    C.Hello Test

    D.Hello Test HelloTest


    正确答案:B

  • 第5题:

    下面程序的输出结果是()。includeinclude"stdng.h"void main(){ char a[]="welcome

    下面程序的输出结果是( )。 #include<iostream.h> #include"stdng.h" void main() { char a[]="welcome",b[]="well"; strcpy(a,b); cout<<a<<endl; }

    A.wellome

    B.wellcom

    C.well

    D.wellwe


    正确答案:C

  • 第6题:

    下面的程序输出的结果是( )。 include using namespace std; void main(){

    下面的程序输出的结果是( )。 #include <iostream> using namespace std; void main(){ int a=2; int &c=a; a++; cout<<c; }

    A.2

    B.3

    C.4

    D.*a


    正确答案:B
    解析:c是a的引用,故a++相当于c++。