更多"下面程序的打印结果是 【11】 。
#include <iostr"的相关试题:
[填空题]下面程序输出的结果是 【11】 。
#include <iostream>
using namespacc std;
class A {
public:
void show( ){tout<<"A!";}
};
class B: public A{
public:
virtual void show( ){cout<<"B!";}
};
class C: public B{
public:
virtual void show( ){cout<<"C!";}
};
void show_info(A *i){i->show( );}
void main( ){
A ia;B ib;C ic;show_info(&ia); show_info(&ib);show_info(&ic);
}
[填空题]下面程序输出的结果是 【10】 。
#include <iostream>
using namespace std;
class A {
public:
virtual void show( ) {cout<<"A!";
};
class B: public A {
public:
void show( ) {cout << "B!";}
};
class C: public B{
public:
void show( ){cout << "C!";}
};
void show_info(A &i) {i. show( );}
void main( ) {
A ia; B ib; C ic; show_info(ia);show_info(ib); show_info(ic); }
[填空题]下面程序的打印结果是 【11】 。
#include <iostream>
using namespace std;
class Base
public:
Base(int x)
a=x;
void show( )
cout<<a;
private:
int a;
;
class Derived : public Base
public:
Derived(int i) :Base(i+1) ,b(i)
void show( )
cout<<b;
private:
int b;
;
int main ( )
Base b(5) , *pb;
Derived d(1);
pb=&d;
pb->show( );
return 0;
[填空题]下面程序的打印结果是______。
#include <iostream>
using namespace std;
class Base
public:
Base(int x)
a=x;
void show( )
cout<<a;
private:
int a;
;
class Derived : public Base
public:
Derived(int i) :Base(i+1) ,b(i)
void show( )
cout<<b;
private:
int b;
;
int main ( )
Base b(5) , *pb;
Derived d(1);
pb=&d;
pb->show( );
return 0;
[填空题]下列程序的输出结果是 【15】 。
#include <iostream>
using namespace std;
class base {
public:
int n;
base(iht x) {n=x;}
virtual void set(int m) {n=m;cout<<n<<’’;}
};
class deriveA: public base {
public:
deriveA(int x):base(x) {}
void set(int m){n+=m;cout<<n<<’’;}
}:
class deriveB:public base {
public:
deriveB(int x):base(x) { }
void set(int m) {n+=m;cout<<n<<’’;}
};
int main( )
deriveA d1(1);
deriveB d2(3);
base *pbase;
pbase=&d 1;
pbase->set(1);
pbase=&d2;
pbase->set(2);
return 0;
[填空题]下列程序的输出结果是 【11】 。
#include <iostream>
using namespace std;
class Test {
public:
Test( ) {cnt++;}
~Test( ) {cnt--;}
static int Count( ) (return cnt;}
private:
static int cnt;
};
int Test::cnt=0;
int main( )
{
cout<<Test::Count( )<<’’;
Test t1, t2;
Test *pT3=new Test;
Test *pT4=new Test;
cout<<Test::Count( )<<’’;
delete pT4;
delete pT3;
cout<<Test::Count( )<<end 1;
return 0;
}
[填空题]下列程序的输出结果是 【10】 。
#include <iostream>
using namespace std;
void fun(int &rf)
rf*=2;
int main( )
int num= 500;
fun(num);
cout<<num<<end1;
return 0;
[填空题]以下程序的输出结果是 【9】 。
#include <iostream>
using namespace std;
void fun( )
{
static int a=0;
a+=2;
cout<<a;
}
int main( )
{
int CC;
for(CC=1;cc<4;CC++)
fun( );
cout<<end1;
return 0;
}
[填空题]以下程序的输出结果是 【10】 。
#include <iostream>
using namespace std;
int main( )
{
char S[ ]="abcdef";
s[3]=’\0’;
cout<<s<<end1;
return 0;
}
[单项选择]以下程序执行后的输出结果是( )。 #include <iostream> using namespace std; void try(int,int,int,int); int main ( ) { int x,y,z,r; x=1; y=2; try(x,y,z,r); cout<<r<<end1; return 0; } void try(int x,int y, int z,int r) { z = x+y; x = X*X; y = y*y; r = z+x+y; }
A. 18
B. 9
C. 10
D. 不确定
[填空题]以下程序执行后输出的结果是 【11】 。
#include<iostream>
using namespace std;
int fac(int a,int b)
return(b-a)*a;
int main( )
int x=3,y=4,z=5,result;
result=fac(fac(x,y),fac(x,z));
cout<<result<<endl;
return 0;
[填空题]下列程序的输出结果是 ______ 。
#include <iostream>
using namespace std;
int main( )
int i=5;
int &r=i;r=7;
cout <<i<<endl;
return 0;
[单项选择]下面程序的执行结果是( )。
#include<iostream>
using namespace std;
class building
public:
building( )
building(unsigned stories, float breadths, float lengths)
story = stories; breadth = breadths; length = lengths;
void getstory(void)
cout<<"story is:"<<story<<endl;
void getarea(void)
area = length*breadth*story;cout<<"area is:"<<area<<endl;
private:
unsigned story;
float length;
float breadth;
float area;
;
void main(void)
building b1,b2;building b3(10u,16.6,58.8);
b1.getstory( );
b1.getarea( );
b2.getstory( );
b2.getarea( );
b3.getstory( );
b3.getarea( );
A. story is:0
B. story is:null
C. 前两个对象输出的结果是不定的,后一个对象的结果正确
D. 前两个对象没有初值,因此程序编译时出错
[单项选择]下面程序的输出结果是( )。
#include<iostream>
using namespace std;
template<class T>
T max(T x,T y)
return(x>= y x:y);
template<class T>
T max(T x,T y,T z)
T t; t=(x>=y x:y);
return(t>=z t:z);
void main( ) int x = 10,y=18,maxi;
float a = 1.2,b = 3.2,c = 2,max2;
max1 = max(x,(int)c);
max2 = max(a,b,(float)y);
cout<<maxi<<endl;
cout<<max2<<endl;
A. 18
B. 10
C. 10
D. 编译出错