// 第二十四章 异常和错误处理//1异常/*#includeusing namespace std;class wrong{};void error(){ cout<<"出错"< using namespace std;const int num=5;class people{public: people(int size=num); people(const people&r); ~people(){delete []p; } people&operator=(const people&r); int &operator[](int off)const; int GetSize()const{ return size;} friend ostream&operator<<(ostream&, const people&); class wrong{};private: int *p; int size;};people::people(int Size):size(Size){ //初始化指针p p = new int[size]; for(int i=0; i =0 && off < _size){//如果值在正常范围内 return p[off]; } throw wrong(); return p[0]; //返回}//重新友元输出符 friend ostream&operator<<(ostream&, const people&)//友元函数的定义不用加类名也不用在前面加班friendostream&operator<<(ostream& out, const people&r){ for(int i=0; i