軟件設計師案例分析當天每日一練試題地址:www.xomuzic.com/exam/ExamDayAL.aspx?t1=4
往期軟件設計師每日一練試題匯總:www.xomuzic.com/class/27/e4_1.html
軟件設計師案例分析每日一練試題(2024/4/18)在線測試:www.xomuzic.com/exam/ExamDayAL.aspx?t1=4&day=2024/4/18
點擊查看:更多軟件設計師習題與指導
軟件設計師案例分析每日一練試題內容(2024/4/18)
試題六
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]; / * 沒有越界提示 * /
}
信管網(wǎng)考友試題答案分享:
信管網(wǎng)試題答案與解析:www.xomuzic.com/exam/ExamDayAL.aspx?t1=4&day=2024/4/18信管網(wǎng)訂閱號
信管網(wǎng)視頻號
信管網(wǎng)抖音號
溫馨提示:因考試政策、內容不斷變化與調整,信管網(wǎng)網(wǎng)站提供的以上信息僅供參考,如有異議,請以權威部門公布的內容為準!
信管網(wǎng)致力于為廣大信管從業(yè)人員、愛好者、大學生提供專業(yè)、高質量的課程和服務,解決其考試證書、技能提升和就業(yè)的需求。
信管網(wǎng)軟考課程由信管網(wǎng)依托10年專業(yè)軟考教研傾力打造,教材和資料參編作者和資深講師坐鎮(zhèn),通過深研歷年考試出題規(guī)律與考試大綱,深挖核心知識與高頻考點,為學員考試保駕護航。面授、直播&錄播,多種班型靈活學習,滿足不同學員考證需求,降低課程學習難度,使學習效果事半功倍。
發(fā)表評論 查看完整評論 | |