#include namespace myspace { template class vector{ public: vector(){} vector(int _N, T _Val); ~vector(); T operator[] (int i); void resize(); int size(){ return N; } ; protected: T** data; int N; }; template vector::vector(int _N, T _Val ):N(_N){ data = new T*[N]; for (int i{0}; i < N; i++){ data[i] = new T(_Val); } } template vector::~vector(){ delete [] data; } template T vector::operator[] (int i){ try { if (i>=0 && i < N){ return *data[i]; } else throw(i); } catch(int i){ std::cout << "out of range, try to access "<< i << " out of " << N <<"\n"; exit(-1); } } /// end of namespace /// }