0
9
10
这是一个无限循环,没有输出
第1题:
以下程序段的输出结果是 [ ] 。
include<iostream.h>
void ref(int &i);
void main(){
int val=1;
cout<<“旧值:”<<val<<end1;
ref(val);
cout<<”新值:”<<val<<end1;
}
void ref(int &i){i=10;}
第2题:
以下程序中,错误的行为 ①#include < iostream.h > ②class A ③{ ④ public: ⑤ int n=2; ⑥ A(int val){cout << val<<end1;} ⑦ ~A( 0{}; ⑧}; ⑨void main( 0 ⑩{ (11) Aa(0); (12)
A.⑤
B.⑥
C.⑦
D.(11)
第3题:
有如下程序:
#include
using namespace std;
int main()
{
void function(double val);
double val;
function(val);
cout<
return 0;
}
void function(double val)
{
val = 3;
}
编译运行这个程序将出现的情况是
A .编译出错,无法运行
B .输出: 3
C .输出: 3.0
D .输出一个不确定的数
第4题:
有如下程序: #include <iostream> using namespace std; class Part{ public: Part(int x=0):val(x) { cout<<val; } ~Part() { cout<<val; } private: int val; }; class Whole { public: Whole(int x, int y, int z=0):p2(x),p1 (y),val(z) { cout<<val; } ~whole() { cout<<val; private: Part p1,p2; int val; }; int main() { Whole obj (1,2,3); return 0; }程序的输出结果是
A.123321
B.213312
C.213
D.123123
第5题:
( 29 )有如下程序:
#include<iostream>
using namespace std;
class Part{
public:
Part(int x=0):val(x) {cout<<val;}
~Part(){cout<<val;}
private:
int val;
};
class Whole{
public:
Whole(int x ,int y, int z=0):p2(x),p1(y),val(z){cout<<val;}
~Whole(){cout<<val;}
private:
Part p1,p2;
int val;
};
int main(){
Whole obj(1,2,3);
return 0;
}
程序的输出结果是
A ) 123321
B ) 213312
C ) 213
D ) 123123
第6题:
下列程序的输出结果为( )。 S1=”1”:S2=”2”:SI=Val(S1)+Val(S2):S2=Val(”12”) If S1S2 Then P int S1-S2 Else Print S2-S1
A.-9
B.9
C.-12
D.0
第7题:
( 28 )有如下程序:
#include<iostream>
using namespace std;
class MyClass{
public:
MyClass(int x):val(x) {}
void Print() const {cout<<"const:val="<<val<<'\t';}
void Print(){cout<<"val="<<val<<'t';}
private:
int val;
};
int main(){
const MyClass obj1(10);
MyClass obj2(20);
obj1.Print();
obj2.Print();
return 0;
}
程序的输出结果是
A ) val=10 const:val=20
B ) const:val=10 const:val=20
C ) const:val=10 val=20
D ) val=10 val=20
第8题:
有以下程序:
include<iostream>
using namespace std;
class MyClass
{
public:
static int s;
MyClass();
void SetValue(int val);
};
int MyClass::s=0;
MyClass::MyClass()
{
S++;
}
void MyClass::SetValue(int val)
{
s=val;
}
int main()
{
MyClass my[3],*p;
p=my;
for(int k=0;k<3;k++)
{
p->SetValue(k+1);
p++;
}
cout<<MyClass::s<<end1;
return 0;
}
运行后的输出结果是______。
第9题:
下列程序的执行结果为( )。 A="1" B="2" A=Val(A)+Val(B) B=Val("12") IfA<>BThenPrint A-B Else Print B-A
A.-9
B.9
C.-12
D.0
第10题:
有如下程序: #include<iostream> using namespace std; class MyClass{ public: MyClass(int x):val(x){} void Print()const{cout<<“const:val=”<<<val<<‘\’;} void Print(){cout<<“val=”<<val<<‘t’;} private: int va1; }; int main(){ cons
A.val=10 const:val=20
B.const:val=10 const:val=20
C.const:val=10 val=20
D.val=10 val=20