c++語言數組越界try catch判斷

#include<iostream.h> template<class T> class Array {     int i; T *ar; public: Array(int c):i(c){ar=new T[c];} void init(int n,T x){ar[n]=x;} T& operator[](int n) { if(n>=i)throw n; return ar[n];} };
相關文章
相關標籤/搜索