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