Can someone check my programming? It's all about templates, and I'm getting all errors. Help!
Declared in main: ========================================== template <class T> class Array { public: Array(int l, int h); Array(int s); Array(const Array& other); ~Array(); T& operator[](int index); const T& operator[](int index) const; int get_size() const {return size;} private: int low; int high; int size; int offset; T *ptr; }; ========================================== My definition for Array(int l, int h): ========================================== template <class T> T Array<T>::Array (int l, int h) { if (l>h) { cout<<"Bad number!\n"<<endl; exit (1); } else { low = l; high = h; size=(-1*l)+h; for (int i=0; i<size; i++) { ptr[i]=false; } } } ========================================= What the instructions said: ===>>> • A two parameter constructor Array(int low, int high) that creates an array with lowest possible index low and highest possible index high. Do not allocate more storage than needed. It is an error if low is greater than high (issue a message and exit(1) in this case).
Join our real-time social learning platform and learn together with your friends!