家长越界行为有哪些?()
A:语言越界 B:行动越界 C:心理越界 D:沟通越界
[说明]
C++语言本身不提供对数组下标越界的判断。为了解决这一问题,在以下[C++程序]中定义了相应的类模板,使得对于任意类型的二维数组,可以在访问数组元素的同时,对行下标和列下标进行越界判断,并给出相应的提示信息。
[C++程序]
#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]; //没有越界提示
阅读下列说明和C++程序,将应填入(n)处的字句写在对应栏内。
[说明] C++语言本身不提供对数组下标越界的判断。为了解决这一问题,在以下[C++程序]中定义了相应的类模板,使得对于任意类型的二维数组,可以在访问数组元素的同时,对行下标和列下标进行越界判断,并给出相应的提示信息。 [C++程序] #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]; //没有越界提示 }
【说明】
C++语言本身不提供对数组下标越界的判断。为了解决这一问题,在程序6中定义了相应的类模板,使得对厂任意类型的二维数组,可以在访问数组元素的同时,对行下标和列下标进行越界判断,并给出相应的提示信息。
#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];
;
~ArrayBody ( ) 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=s2[10][20]; //有越界提示:行下标越界[10]列下标越界[20]
b2=a2[1][4]; //没有越界提示
【说明】 C++语言本身不提供对数组下标越界的判断。为了解决这一问题,在程序6中定义了相应的类模板,使得对厂任意类型的二维数组,可以在访问数组元素的同时,对行下标和列下标进行越界判断,并给出相应的提示信息。 #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]; }; ~ArrayBody ( ) { 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=s2[10][20]; //有越界提示:行下标越界[10]列下标越界[20] b2=a2[1][4]; //没有越界提示 }
阅读下列说明和C++程序,将应填入横线处的语句写在答题纸的对应栏内
[程序6说明]
C++语言本身不提供对数组下标越界的判断。为了解决这一问题,在程序6中定义了相应的类模板,使得对于任意类型的二维数组,可以在访问数组元素的同时,对行下标和列下标进行越界判断,并给出相应的提示信息。
[程序6]
#include<ioStream.h>
template<class T>class Array;
template<class T>class ArrayBody{
friend (1) ;
T* tpBody;
int iRows,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=;
if(j<0|| j≥iColumns
column_error=;
if(row_error==true || column_error==true)
(3) ;
}
eatch(char) {
if(row error==true)
cerr<<“行下标越界[“<<iCurrentRow<<”]”;
if(column error==true)
cerr<<“列下标越界[“<<j<<”]”;
cout<<“/n”;
}
return tpBody[iCurrentRow * iColumns+j];
}
~ArrayBody( ){delere[]tpBody;}
};
template<class T>class Array {
ArrayBody<T> tBody;
public:
ArrayBody<T> & operator[](int i){
(4) ;
return tBody;
};
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]; / * 没有越界提示 * /
}
(1)class Array<T> (2)new T[iRsz * iCsz] (3)throw’e’
关于超越界,下面说法正确的是:
A:只有zōng jiāo 才有超越界 B:超越界是生活的基础和最终依据 C:超越界必须在生活之外寻找 D:信仰是连通人与超越界之间的桥梁