/*********************************************************** Copyright 2003 Rick Miller - Pulp Free Press This source code accompanies the text C++ For Artists and is provided for instructional purposes only. No warranty concerning the quality of the code is expressed or implied. You are free to use this code in your programs so long as this copyright notice is included in its entirety. **********************************************************/ #ifndef _DYNAMIC_ARRAY_H #define _DYNAMIC_ARRAY_H template class DynamicArray{ public: DynamicArray(int _size = 5); virtual ~DynamicArray(); T& operator[](unsigned i); int getSize(); private: T* its_array; int size; }; template DynamicArray::DynamicArray(int _size):size(_size){ its_array = new T[_size]; for(int i=0; i(0); } template DynamicArray::~DynamicArray(){ delete[] its_array; } template T& DynamicArray::operator[](unsigned i){ if(i >= (size)){ int newsize = size+10; T* temp = new T[size]; for(int j = 0; j(0); } delete[] temp; size = newsize; return its_array[i]; } else return its_array[i]; } template int DynamicArray::getSize(){ return size;} #endif