问题 问答题

请使用“答题"菜单或使用VC6打开考生文件夹proj1下的工程proj1,该工程含有一个源程序文件proj1.cpp。程序中位于每个//ERROR************found************下的语句行有错误。请改正这些错误,改正后程序的输出应该是:
1 2 3 4 5 6 7 8 9 10
注意:只修改注释//ERROR************found************下的一行语句,不要改动程序中的其他内容。
//源程序proj1.cpp
#include<iostream>
using namespace std;
class MyClass
public:
MyClass(int len)
array=new int[len];
arraySize=len;
for(int i=0;i<arraySize; i++) array[i]=i+l;

~MyClass()
//ERROR************found************
delete array[];

void Print() const
for(int i=0;i<arraySize; i++)
//ERROR************found************
cin<<array[i]<<";
cout<<endl;

prlvate:
int*array;
int arraySize;

int main()
//ERROR************found************
MyClass obj;
obj.Print();
return 0:

答案

参考答案:1)delete array;
2)cout<<array[i]<<";
3)MyClass obj(10);

解析:1)释放数组,后面不加[],只需要数组名即可。
2)打印1 2 3 4 5 6 7 8 9 10,应该用cout对象,而不是cin。后面的插入运算符也暗示了答案。
3)按照题目的要求,要打印1~10,所以应该是创建一个有10个数的数组对象,所以在创建obj时,应该带上参数10。

解答题
选择题