更多"下列程序中划线处正确的语句是( )。#include <iostre"的相关试题:
[单项选择]下列程序中划线处正确的语句是( )。
#include <iostream>
using namespace std;
class Basepublic:
void fun( ) cout<<"Base:: fun"<<end1;
;
class Derived: public Base void fun( )
_______________________ //显试调用基类的函数 fun( )
cout <<"Derived:: fun"<<end1;
;
A. fun();
B. Base. fun();
C. Base:: fun();
D. Base->fun();
[填空题]下列程序输出结果是 【13】 。
include <iostream>
using namespace std;
template <typename T>
T fun(T a, T b) return (a<=b)a:b;
int main( )
cout<<fun(3,6)<<’,’<<fim(3.14F, 6.28F)<<end 1;
return 0;
[单项选择]下面程序的运行结果是( )。 #include <iostream> using namespace std; template <class T> class A{ T x,y; public: A(T a,T b){x=a;y=b;} int add( ){return x+y;} }; void main( ){ A<double>a(7.8,3.4); A<char>b(7.8,3.4); cout<<a.add( )<<","<<b.add( ); }
A. 10,10
B. 11,11
C. 11,10
D. 以上答案都不对
[填空题]下面程序的运行结果是 【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;
[单项选择]下列程序的运行结果为( )。
#include <iostream>
using namespace std;
namespace m
int flag = 10;
namespace n
flag = 100;
void mian( )
int flag = 0;
using namespace n;
cout<<flag<<","<<m:: flag;
A. 100,10
B. 100,0
C. 0,100
D. 0,10
[填空题]以下程序的输出是 【8】 。
#include<iostream>
using namespace std;
fun(intm)
{
static int n=1;
n=m*n;
return(n);
}
void main( )
{
int i;
for(i=1;i<=3;i++) cout<<fun(i);
}
[单项选择]以下程序的输出结果是( )。 #include <iostream> using namespace std; int main( ){ int a=1,b; switch(a){ case 1:b=30; case 2:b=20; case 3:b=10; default:b=0; } cout<<b<<endl; return 0; }
A. 30
B. 20
C. 10
D. 0
[单项选择]下面程序的运行结果为( )。
#include <iostream>
using namespace std;
class A
public:
A( )cout<<" ";
~A( )cout<<" ";
class B:public A
public:
B( )cout<<" ";
~B( )cout<<" ";
void main( )
B b;
A. 1234
B. 1324
C. 1342
D. 3142
[填空题]下面程序执行的结果是 【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);
[单项选择]下面程序输出的结果是( )。
#include <iostream>
using namespace std;
void swap(int &a,int &b)
int temp;
temp=a;
a=b;
b=temp;
void main( )
int x=2;
int y=3;
swap(x,y);
cout<<x<<y;
A. 23
B. 32
C. ab
D. ba
[单项选择]以下程序段共有错误( )处。 #include <iostream> using namespaces std; class Sample { private: int n; public: Sample(int i) { n=i; } void setvalue (int i) { n=i; } void display( ) { cout<<”n=”<<n<<endl; } }; int main( ) { const Sample a(10); a.setvalue(5); a.display( ); return 0; }
A. 1
B. 2
C. 3
D. 4
[单项选择]下面程序的输出结果是( )。
#include <iostream>
using namespace std;
void main( )
int i,j,m=0,n=0;
for(i=0;i<2;i++)
for(j=0;j<2;j++)
if(j> =i) m=1;n++;
cout<<m<<endl;
cout<<n;
A. 1
B. 1
C. 1
D. 0