填空题
下面程序编译时发现ma[3]=9错误,其原因是{{U}} 【11】 {{/U}}。
# include<iostream. h>
class FunArray
{
int *pa; //指向一个数组空间
int size; //数组元素个数
public:
FunArray(int a[ ], int thesize): pa(A) , size(thesize) { }
int Size( ){return size;}
}
};
void main( )
{
int s[ ]={3,7,2,1,5,4};
FunArray ma (s, sizeof (s)/sizeof(int) );
ma[3] = 9
cout<<ma[3]<<end1;
}
【正确答案】
1、没有重载[]运算符
【答案解析】[解析] ma不是一般的数组,而是一个新定义的类,尽管该类封装了一个数组,但新类并没有提供[]操作符的具体实现,因此是错误的。