更多"下列程序输出结果为: #include<iostream> usi"的相关试题:
[填空题]下列程序输出结果为:
#include<iostream>
using namespace std;
class TestClass1
public:
TestClass1( )
TestClass1(int i)
x1=i;
void dispa( )
cout<<"x1="<<x1<<",";
private:
int x1;
;
class TestClass2:public TestClass1
public:
TestClass2( )
TestClass2(int i):TestClass1(i+10)
x2=i;
void dispb( )
dispa( );
cout<<"x2="<<x2<<endl;
private:
int x2;
;
int main( )
TestClass2 b(2);
b.dispb( );
return 0;
[单项选择]如下程序的输出结果是 #include<iostream> using namespace std; class A{ public: virtual void f( ){tout<<1;} void g( ){cout<<2;} }; class B:public A{ public: virtual void f( ){cout<<3;} void g( ){cout<<4;} }; void show(A&A) {a.f( );a.g( );} int nlain( ){ B b; show(B) ; return 0; }
A. 12
B. 34
C. 14
D. 32
[单项选择]下列程序的输出结果是
#include"iostream"
using namespace std;
int Max(int a,int b)
{
if(a>b)
return a;
else
return b;
}
void main( )
{
int m,n;
m=10,n=5;
int max=Max(m,n);
cout<<max<<endl;
}
A. 10
B. 程序有误
C. 1
D. 0
[单项选择]下列程序的输出结果是() #inClUde<iostream> using namespace std; intmain( ) { Char a[]="HellO,World"; Char*ptr=a; while(*ptr) { if(*ptr>=’a’&& *ptr <=’Z’) cout<<char(*ptr+’A’ -’a’); else cout<<*ptr; ptr++; } retur0; }
A. HELLO,WORLD
B. Hello,world
C. hELLO,wORLD
D. hellO,world
[单项选择]如下程序的输出是
#include<iostream>
using namespace std;
class Base
public:
Base( )cout<<"BB";f( );
void f( )cout<<"Bf";
;
class Derived:public Base
public:
Derived( )eout<<"DD";
void f( )cout<<"Df";
;
int main( )Derived d;return 0;
A. BBBff)D
B. BBDfDDDf
C. DD
D. DDBBBf
[单项选择]如下程序的输出结果是
#include<iostream>
using namespace std;
class MyClass
public:
MyClass(int i=0)cout<<1;
MyClass(const MyClass&x)cout<<2;
;
int main( )
MyClass objl(1),obj2(2),ohj3(objl);
return 0;
A. 112
B. 111
C. 121
D. 113
[单项选择]下列程序的输出结果是
#include" iostream"
using namespace std;
int Max(int a,int b)
if(a > b)
else
return a;
else
retum b;
void main( )
int m,n;
m=10,n=5;
int max=Max(m,n);
cout < < max < < end1;
A. 10
B. 程序有误
C. 1
D. 0
[单项选择]有以下程序 #include <iostream> using namespace std; class Complex { public: Complex (double r=0, double i =0 :re(r) ,im (i) {} double real( ) const {return re;} double imag( ) const { return im;} Complex operator + (Complex c} const {return Complex(re+c.re, im+c.im);} privane: double re,im; }; int main { Complex a =Complex(1,1)+Complex(5); cout<<a.real( )<<’+’<<a.imag( ) << ’i’ <<endl return 0; } 程序执行后的输出结果是
A. 6+6i
B. 6+1i
C. 1+6i
D. 1+1i
[单项选择]给出下面程序的输出结果。
#include<iostream>
using namespace std;
void main( )
int num=0,i=8;
do
i--;
num++;
while(--i);
cout<<nun<<endl;
[填空题]有如下程序:
#include<iostream>
using namespace std;
class CA{
public:
CA( ){cout<<’A’;}
};
class CB:private CA{
public:
CB( ){cout<<’B’;}
};
int main( ){
CA a;
CB b;
return 0;
{
运行时的输出结果是______。
[填空题]有下列程序:
#include<iostream>
using namespace std;
class ONE
{
public:
virtual void f( ){COUt<<"1";}
};
c1assTWO:public ONE
{
public:
TWO( ){cout<<"2";}
};
class THREE:public TWO
{
public:
virtual void f( ){TWO∷f( );cout<<"3";}
};
int main( )
{
ONE aa,*p;
TWO bb;
THREE cc;
p=&cc;
p->f( );
return 0;
}
执行上面程序的输出结果是______。