请使用VC6或使用[答题]菜单打开考生文件夹proj1下的工程proj1,此工程中含有一个源程序文件proj1.cpp。其中位于每个注释“//ERROR****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为:
Constructor called.
The value is 10
Max number is 20
Destructor called.
注意:只能修改注释“//ERROR****found****”的下一行语句,不要改动程序中的其他内容。
// proj1.cpp
#include <iostream>
using namespace std;
class MyClass
public:
//ERROR**********found**********
void MyClass(int i)
value=i;cout<<"Constructorcalled."<<endl;
int Max(int x,int y)return x>yx:y;//求两Ai整数的最大值
//ERROR**********found**********
int Max(int x,int y,int z=0)
//求三个整数的最大值
if(x>y)
return x>zx:z;
else
return y>zy:z;
int GetValue( )constreturn value;
~MyClass( )cout<<"Destructorcalled."<<endl;
private:
int value;
;
int main ( )
MyClass obj(10);
cout<<"The value is"<<value( )<<endl;
cout<<"Max number is"<<obj.Max(10,20)<<endl;
return 0;
题库:计算机等级考试
类型:简答题
时间:2017-07-03 14:15:43
免费下载:《问答》Word试卷
请使用VC6或使用[答题]菜单打开考生文件夹proj1下的工程proj1,此工程中含有一个源程序文件proj1.cpp。其中位于每个注释“//ERROR****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为:
Constructor called.
The value is 10
Max number is 20
Destructor called.
注意:只能修改注释“//ERROR****found****”的下一行语句,不要改动程序中的其他内容。
// proj1.cpp
#include <iostream>
using namespace std;
class MyClass
public:
//ERROR**********found**********
void MyClass(int i)
value=i;cout<<"Constructorcalled."<<endl;
int Max(int x,int y)return x>yx:y;//求两Ai整数的最大值
//ERROR**********found**********
int Max(int x,int y,int z=0)
//求三个整数的最大值
if(x>y)
return x>zx:z;
else
return y>zy:z;
int GetValue( )constreturn value;
~MyClass( )cout<<"Destructorcalled."<<endl;
private:
int value;
;
int main ( )
MyClass obj(10);
cout<<"The value is"<<value( )<<endl;
cout<<"Max number is"<<obj.Max(10,20)<<endl;
return 0;
本题关键词:工程使用年限,程序性文件,保温工程使用年限,工程合理使用年限,工程变更文件,工程设计文件,建设工程文件,其他构件工程,工程施工管理文件,建筑工程设计使用年限;