求助各位高手
有代码如下,帮忙填5个空格~~~~~~
#include <iostream.h>
template <class T> class Array;
template <Class T> class ArrayBody {
friend__(1)__;
T* tpBody;
int iRows,iColumns,iCurrentRow;
ArrayBody(int iRsz,int iCsz){
tpBody = __(2)__;
iRows = iRsz;iColumns = iCsz;iCurrentRow = -1:
}
public:
T& operator[](int j){
bool row_error,column_error;
row_error = column_error =false;
try {
if(iCurrentRow < 0 || iCurrentRow >= iRows)
row_error = true;
if(j<0 ||j>= iColumns)
column_error = true;
if(row_error == true || column_ error == true)
__(3)__;
}
catch(char){
if(row_error == true)
cerr << "行下标越界[" << iCurrentRow << "]";
if(column_error = true)
cerr << "列下标越界[" << j << "]";
cout << "\n";
}
return tpBody[iCurrentRow * iColumns + j];
}
~Arraygody(){delete[]tpBody;}
};
template <class T> class Array {
ArrayBody<T> tBody;
public:
ArrayBody<T> & operator[](int i) {
__(4)__;
return tBody;
}
Array(int iRsz,int iCsz):__(5)__ { }
};
void main()
{
Array<int> a1(10,20);
Array<double> a2(3,5);
int b1;
double b2;
b1 = a1[-5][10]; //有越界提示:行下标越界[-5]
b1 = a1[10][15]; //有越界提示:行下标越界[10]
b1 = a1[1][4]; //没有越界提示
b2 = a2[2][6]; //有越界提示:列下标越界[6]
b2 = a2[10][20]; //有越界提示;行下标越界[10]列下标越界[20]
b2 = a2[1][4]; //没有越界提示
}