#ifndef SAFE_VECTORS #define SAFE_VECTORS #include #include "d_except.h" using namespace std; template class safeVector: public vector { public: safeVector(): vector() {} safeVector(T *first, T *last): vector(first,last) {} safeVector(int n, const T& value = T()): vector(n,value) {} T& operator[] (int i) { if (i < 0 || i >= size()) throw indexRangeError( "safeVector: index range error", i, size()); // execute the index operator in the vector base class // and pass it the argument i return vector::operator[] (i); } }; #endif // SAFE_VECTORS