请使用VC6或使用[答题]菜单打开考生文件夹proj1下的工程proj1,此工程中含有一个源程序文件proj1.cpp。其中位于每个注释“//ERROR ****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为:
Constructor called.
The value is 10
Copy constructor called.
The value is 10
Destructor called.
Destructor called.
注意:只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。
//proj1.cpp
#include <iostream>
using namespace std;
class MyClass
public:
//ERROR **********found**********
MyClass(int i)
value=i;cout<<"Construc-tor called."<<endl;
//ERROR **********found**********
MyClass(const MyClass p)
value=p.value;
cout<<"Copy constructorcalled."<<endl;
void Print ()
cout<<"The value is"<<value<<endl;
//ERROR **********found**********
void ~MyClass()
cout<<"Destructor called."
<<endl;
private:
int value;
;
int main()
MyClass obj1;
obj1.Print();
MyClass obj2(obj1);
obj2.Print();
return 0;