資源簡(jiǎn)介
4.3 設(shè)計(jì)一個(gè)一維的int數(shù)組類IntArray(屬性:下標(biāo)下 限、下標(biāo)上限、int型指針),可以任意指定下標(biāo)范圍(初始化時(shí)要判斷下標(biāo)是否正確),并重載下標(biāo)訪問(wèn)運(yùn)算符“[]”實(shí)現(xiàn)數(shù)組類的下標(biāo)訪問(wèn)。在主函數(shù)中(創(chuàng)建一個(gè)下標(biāo)1-10的數(shù)組對(duì)象,初始化并輸出)進(jìn)行測(cè)試。
代碼片段和文件信息
#include//241
#include
#include
using?namespace?std;
class?Mistake{
private:
string?str;
public:
Mistake():str(“目前無(wú)法計(jì)算負(fù)數(shù)的平方根!“){};
void?show(){?cout?<};
void?Getsqrt(double?n){
Mistake?aa;
if?(n<0)
throw?aa;
評(píng)論
共有 條評(píng)論