更多"下面程序的打印结果是 【11】 。 #include <iostre"的相关试题:
[填空题]下面程序的打印结果是 【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;
[填空题]下面程序的运行结果是 【8】
#include <iostream>
using namespace std;
int fun(int n)
{
static int m = 2;
m=m+n;
return m;
}
int main ( )
{
int a = 3, b = 4;
int x;
x = fun( a );
x = fun( b );
cout<<x<<end1;
return O;
}
[填空题]下面程序执行的结果是 【14】
#include<iostream>
using namespace std;
class A{
public:
static int x;
A(inty){cout<<x+y;}
};
int A::x=2;
void main( ){
A a(5);
}
[填空题]下面程序的输出结果是 【13】 。
#include <iostream>
using namespace std;
class A
int a, b;
public:
A( )
a = b = 0;
A(int aa, int bb ) : a(aA) , b(bB)
cout <<"a="<<a<<","<<"b="<<b<<",";
~A( )
cout<<"D";
;
int main ( )
A x, y(2, 3);
return 0;
[填空题]下面程序的输出结果是 【15】 。
#include <iostream>
using namespace std;
class base
protected:
int a;
public:
base( )cout<<"0":
;
class basel: virtual public base
public:
base1( ) cout<<"1";
;
class base2 : virtual public base
public:
base2( )cout<<"2";
;
class derived : public base1,public base2
public:
derived ( ) cout<<"3";
int main ( )
derived obj;
cout<<end1;
return 0;
[填空题]下面程序输出的结果是
【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(&i
- a); show_info(&i
- b);show_info(&i
- c);
[填空题]下面程序输出的结果是
【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(i
- a);show_info(i
- b); show_info(i
- c);
[填空题]下面程序的输出结果是 【8】 。
#include<iostream>
using namespace std;
int x;
void funA(int&,int);
void funB(int,int&);
int main( )
{
int first;
int second=5;
x=6;
funA(first,seconD) ;
fimB(first,seconD) ;
cout<<first<<" "<<second<<" "<<x<<end1;
return 0;
}
void funA(int &a,int B)
{
int first;
first=a+b;
a=2*b;
b=first+4;
}
void funB(int u,int &v)
{
int second;
second=x;
v=second+4;
x=u+v;
}
[填空题]下面程序执行的结果是 【15】 。
#include <iostream>
using namespace std;
void main( )
int sum=0;
int array[6]=1,2,3,4,5,6;
int *p;
p=&array[0];
for(int i=0;i<6;i++)
sum=sum+*p;
p++;
cout<<sum;
[填空题]下列程序的输出结果是 【13】
#include<iostream>
using namespace std;
template<typenameT>
Tfun(Ta,TB) {return (a<=B) a:b;}
int main ( )
{
cout<<fun(3,6)<<’,’<<fun(3.14F,6.28F)<<end1;
return 0;
}
[填空题]下列程序的输出结果是 【9】 。
#include<iostream>
using namespace std;
int main( ){
int i=3;
int &r=i; r=5;
cout<<i<<endl;
return 0;
}
[填空题]以下程序的输出结果是 【10】 。
#include <iostream>
using namespace std;
int main( )
char S[ ]="abcdef";
s[3]=’\0’;
cout<<s<<end1;
return 0;
[填空题]下列程序的输出结果是 【14】 。
#include <iostream>
using namespace std;
template <typename T>
T total (T *data)
{
T s = 0;
while(*data)
{
s+=*data++;
}
return s; }
int main( )
{
int x[]={2,4,6,8,0,12,14,16,18};
cout<<total(x)<<end1;
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;