更多"下面这个程序的结果是 #include<iostream.h> "的相关试题:
[单项选择]下面这个程序的结果是
#include<iostream.h>
class A
private:
int a;
public:
void seta( );int geta( );;
void A::seta( )
a = 1;
int A::geta( )
return a;
class B
private:
int a;
public:
void seta( );int geta( );;
void B::seta( )
a=2;
int B::geta( )
return a;
class C://public A,public B
private:
int b;
public:
void display( );;
void C::display( )
int b=geta( );
cout <<b;
void main( )
C c;
c.seta( );
c.display( );
A. 1
B. 2
C. 随机输出1或2
D. 程序有错
[单项选择]下面这个程序的结果是
#include<iostream.h>
class A
private:
int a;
public:
void seta( ) ;int geta( ) ;;
void A: :seta( )
a=1;
int A: :geta( )
retum a;
class B
private:
int a;
public:
void seta( ) ;int geta( ) ;;
void B: :seta( )
a=2;
int B: :geta( )
return a;
class C: public A,public B
private:
int b;
public:
void display( ) ;;
void C: :display( )
int b=geta( ) ;
cout < < b;
void main( )
C c;
c. seta( ) ;
c. display( ) ;
A) 1 B) 2
C) 随机输出1或2 D) 程序有错
[单项选择]下面程序的结果是
#include<iostream.h>
class A
public:
A( ) cout < < "construtA" < < end1;
virtual ~A( ) cout < < "destructA" < < end1; ;
class B:public A
;
class C://public A
;
class D://public B,public C
;
void main( )
Dd;
A. constructA
B. constructA
C. constructA
D. constructA
[单项选择]下面程序的结果是 #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; public: C( ):a(3) { } void showa( ) {cout < < a;} }; void main( ) { C c; c.showa( ); }
A. 1
B. 2
C. 3
D. 程序有错误
[单项选择]下面程序的结果是 #include<iostream.h> class test{ private: int num; public: test( ); int getint( ) {return num;} ~test( );}; test::test( ) { num=0;} test::~test( ) { cout<<"Destructor is active"<<endl;} void main( ) { test x[3]; cout<<"Exiting main"<<endl;}
A. Exiting main Destructor is active Destructor is active Destructor is active
B. Exiting main Destructor is active Destructoris active
C. Exiting main Destructoris active
D. Exiting main
[单项选择]下面程序的结果是 #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( ) { D d;}
A. constructA destructA
B. constructA constructA destructA destructA
C. constructA constructA constructA destructA destructA destructA
D. constructA onstructA constructA constructA destructA destructA destructA destructA
[单项选择]下面程序的运行结果是
#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 <<end1;
A. 0123
B. 3120
C. 0312
D. 3012
[单项选择]下面程序的结果是( )。
#include<iostream.h>
class test{ private:
int num;
public:
test( );
int getint( ) {return num;}
~test( );};
test::test( )
{ num=0;}
test::~test( )
{ cout<<"Destructor is active"<<endl;}
void main( )
{ test x[3];
cout<<"Exiting main"<<endl;}
[单项选择]分析下面程序,该程序的运行结果是( )。
#include<iostream.h>
class cmm
public:
static int m;
cmm( )
m++;
cmm(int n)
m=n;
static void testm( )
m++;
;
int cmm :: m=0;
void main( )
cmm A;
cmm B(3);
A. testm();
B. m=3
C. m=4
D. m=5
E. m=6
[单项选择]下面程序的结果是
#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
t a;
public:
C( ) :a(3)
void showa( ) cout < < a;
;
void main( )
C c;
c.showa( ) ;
A. 1
B. 2
C. 3
D. 程序有错误
[单项选择]下面程序的运行结果是( )。
#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. 123
B. 3120
C. 312
D. 3012
[单项选择]下面程序的运行结果是( )。
#include<iostream.h>
class Sampleint x, y;
public:
Sample( ) x=y=0;
Sample(int a, int b) x=a; y=b;
void (lisp( )cout<<"x="<<x<<",y="<<y<<end1;;
void main( )Sample s(2,3), *p=&s;
p->disp( );
A. x=1, y=2
B. x=2, y=4
C. x=2, y=3
D. x=4, y=3
[单项选择]下面程序的结果是( )。
#include<iostream.h>
class A
int a;
public:
A. 1
B. 2
C. 3
D. 程序有错误