更多"以下程序的执行结果是 【15】 。 #include<iostre"的相关试题:
[单项选择]以下程序执行结果是 ( )。
#include <iostream.h>
class Base
public
virtual void fun( ) cout<<"B";
;
class Derived
public:
Derived( ) cout<<"D";
virtual void fun( ) Base::fun( ); cout<<"C";
int main ( )
Base *ptr;
Derived obj;
ptr=&obj;
p->fun ( );
return 0;
A. DBC
B. DCB
C. BDC
D. CBD
[单项选择]以下程序执行后的输出结果是 ( )。
#include <iostream.h>
class Basel
public:
void fun( ) cout<<"Basel"<<end1;
;
class Base2
public:
void fun( ) cout<<"Base2"<<end1;
class Derived : public Basel,public Base2
;
void main( )
Derived Obj;
Obj.fun( );
A. Basel
B. Base2
C. BaselBase2
D. 程序产生二义性
[填空题]以下程序的执行结果是 【10】 。
#include<iostream.h>
class Sampleint n;
public:
Sample( )
Sample(int m) n=m;
int &operator--(int)n--;
return n;void disp( ) cout<<"n="<<n<<end1;
;
void main( )Sample s(10);
(s--)++;
s. disp( );
[填空题]以下程序的执行结果是______。
#include<iostream.h>
class A
int a;
public: void seta(int x) a=x;
void showa( ) cout<<a<<endl;
;
class B
int b;
public:
void setb(int x) b=x;
void showb( ) cout<<b<<endl:
;
class C://public A,private B
private:
int c;
public:
voidsetc (intx,inty,intz)
c=z;
seta(x);
setb(y);
void showc( )cout<<c<<endl;
;
void main( )
Cc;
C.seta(1);
C.showa( );
C.setc(1,2,3);
C.showc( );
[填空题]以下程序的执行结果是______。
#include<iostream.h>
class Sample
{
int n;
public:
Sample( ){}
Sample(int m){n+m;)
int&operator--(int)
{
n--
return n;
}
void disp ( ) {cout<<"n= "<<n<<end1;}
}
void main ( )
{
Sample s (10);
(s--) ++;
s.disp( );
}
[填空题]以下程序的执行结果是______。
#include<iostream.h>
class Sample
int n;
public:
Sample( )
Sample(int m)n+m;)
int&operator--(int)
n--
return n;
void disp ( ) cout<<"n= "<<n<<end1;
void main ( )
Sample s (10);
(s--) ++;
s.disp( );
[填空题]以下程序的执行结果是______。
#include <iostream.h>
class Sample
int n;
public:
Sample( )
Sample(int m) n=m;
int &operator--(int)
n--;
return n;
void disp( ) cout<<"n="<<n<<endl;
;
void main( )
Sample s(10);
(s--)++;
s.disp( );
[填空题]以下程序的执行结果是______。
#include<iostream.h>
class CSample
private:
int n;
static int k:
public:
CSample (int i) n=i;k++;;
voiddisp( );
;
void CSample::disp( )
cout <<"n="<<n<<",k="<<k<<endl
int CSample::k=0
void main( )
CSample a(10),b(20),c(30);
a.disp( );
b.disp( );
c.disp( );
[填空题]以下程序的执行结果是______。
#include<iostream.h>
class A
int a:
public:
void seta(int x) a=x;
void showa( ) cout<<a<<end1;
;
class B
int b;
public:
void setb(int x) b=x;
void showb( )cout<<b<<end1;
;
class C: public A,private B
private:
int c:
public:
voidsetc(intx,inty,intz)
c=z;
seta(x);
setb(y);
void showc( )cout>>c<<end1;
;
void main( )
Cc:
C.seta(1);
C.showa( );
C.setc(1,2,3);
C.showc( );
[填空题]以下程序的执行结果是________。
#include<iostream.h>
class base
public:
virtual void who( ) cout<<"base class"<<end1;
;
class derrvel: public base
public:
void who( ) cout<<"derivel class"<<end1;
;
class derive2:public base
public:
void who( )cout<<"derive2class"<<end1;
;
void main( )
base obj1,*P;
derivel obj2;
derive2 obj3;
p=&obj1:
p->who( );
p=&obj2;
p->who( );
p=&obj3;
p-->who( ):
[单项选择]下列程序执行结果是
#include <iostream.h>
class A
public:
int a;
A( ):a(10)cout<<a<<endl;
;
void main( )
A obj1;
A obj2(obj1);
cout<<" "<<obj2.a<<endl;
A. 10 10
B. 编译错误缺少拷贝构造函数
C. 10随机数
D. 随机数随机数
[单项选择]下面程序的结果是
#include
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 object
private:
int val;
public:
object( ) ;
object(int i) ;
~object( ) ;;
object: :object( )
val=0;
cout < < "Default constructor for object" < < endl;
object: :object(int i)
val=i;
cout < < "Constructor for object" < < val < < endl;
object: :~object( )
cout < < "Destructor for object" < < val < < endl;
class container private:
object one;
object two;
int data;
public:
container( ) ;
container(int i,int j,int k) ;
~container( ) ;;
container: :container( )
data=0;
cout < < "Default constructor for container" < < endl;
container: :container(int i,int j,int k) :two(i) ,one(j)
data=k;
cout < < "Constructor for container" < < endl;
container: :~container( )
cout < < "Destructor for container" < < endl;
void main( )