更多"下面程序的运行结果为 #include<iostream.h> c"的相关试题:
[单项选择]下面程序的运行结果为
#include<iostream.h>
class A
static int n;
public:
A( )n=1;
A(intnum)n=num;
void print( )cout <<n;
;
int A∷n=2;
void main( )
Aa,b(3);
a.print( );
b.print( );
cout <<end1;
A. 11
B. 13
C. 23
D. 33
[单项选择]下面程序的运行结果为
#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;
A. 1234
B. 1324
C. 1342
D. 3142
[单项选择]下面程序的运行结果为
#include<iostream.h>
class A
int num;
public:
A(int) num=i;
A. voidprint( ) cout < < num;
B. voidmain( )
C. Aa(1) ,b(a) ;
D. a. print( ) ;
E. b. print( ) ;A) 11
F. B)12
G. C)21
H. D)22
[单项选择]下面程序的运行结果为
#include<iostream.h>
claSS A
static int n;
public:
A( )n=1;
A(int num)n=num;
void print( )cout< ;
int A::n=2;
void main( )
Aa,b(3);
a.print( );
b.print( );
cout<<endl;
A. 11
B. 13
C. 23
D. 33
[单项选择]下面程序的运行结果是
#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";
;
class derived:public basel,public base2
public:
derived( )cout<<"3";
;
void main( )
derived obj;
cout<<endl;
A. 0123
B. 3120
C. 0312
D. 3012
[单项选择]下面程序的运行结果为
#include<iostream.h>
class A
{
int num;
public:
A(int) {num=i;}
A(A & a) {hum=a. num++;}
void print( ) {cout < < num;}
};
void main( )
{
A a(1) ,b(a) ;
a. print( ) ;
b. print( ) ;
}
A) 11 B) 12 C) 21 D) 22
[单项选择]下面程序的运行结果为
# 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;
A. 1234
B. 1324
C. 1342
D. 3142
[单项选择]下面程序的运行结果是
#include<iostream.h>
class base{
protected:
int a;
public:
base( ) {cout < < "0";}
};
class base l: virtual base{
public:
base l ( ) {cout < <"1";}
};
class base 2: virtual base{
public:
base2 ( ) {cout < <"2";}
};
class derived: public base 1, public base2{
public:
derived( ) {cout < < "3";}
};
void main( )
{
derive obj;
cout < < endl;
}
A) 0123 B) 3120 C) 0312 D) 3012
[单项选择]下面程序的运行结果为
#include<iostream.h>
Class A
static int n;
public:
A( ) {n=1;}
A(int num) {n=num;}
void print( ) {cout < < n;}
};
int A: :n=2;
void main( )
{
A a,b(3) ;
a. print( ) ;
b. print( ) ;
cout < < endl;
}
A) 11 B) 13 C) 23 D) 33