2026年01月26日来源:信管网 作者:cnitpm
软件设计师案例分析当天每日一练试题地址:www.cnitpm.com/exam/ExamDayAL.aspx?t1=4
往期软件设计师每日一练试题汇总:www.cnitpm.com/class/27/e4_1.html
软件设计师案例分析每日一练试题(2026/1/25)在线测试:www.cnitpm.com/exam/ExamDayAL.aspx?t1=4&day=2026/1/25
点击查看:更多软件设计师习题与指导
软件设计师案例分析每日一练试题内容(2026/1/25)
试题六
11、[程序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]; / * 没有越界提示 * /
}
信管网考友试题答案分享:
信管网cnit**************:
(1)class array<t>
(2)new t(irsz*icsz)
(3) throw “e“
(4) tbody.icurrentrow=i
(5) tbody(irsz.icsz)
温馨提示:因考试政策、内容不断变化与调整,信管网提供的以上信息仅供参考,如有异议,请考生以权威部门公布的内容为准!