更多"如下程序的输出结果是 #include<iostream> u"的相关试题:
[单项选择]如下程序的输出结果是
#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;
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;
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 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
[填空题]下列程序的输出结果是 【8】
#include<iostream>
using namespace std;
int &qetVar(int *pint) renurn *pint;int main ( ) int a =10;
getVar(&a) = 20;
cout<<a<<end1;
return 0;
[填空题]下列程序输出结果为:
#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 Base{
public:
int m,n;
};
class Derived1: _______【 】 Base{};
class Derived2:public Derived1{
public:
void SetMN(int M,int N){m=M;n=N;}
int GetSumMN( ){return(m+n);}
};
int main( ) {
Derived2 objD;
ohjD. SetMN(3,4);
cout<<"M+N="<<objD, m+objD, n<<endl;
return 0
}
编译时只有“cout<<"M+N"<<objD.m+objD.n<<endl;”有语法错误,程序的其他地方没有语法错误。请判断下划线处使用的关键字是什么。
[填空题]下列程序输出结果为:
#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;