/* vector.H This is the vector.h provided by the Weiss text. The only substantial change made is to remove the '#include vector.cpp' line at the end. Additionally, the name has been changed to .H from .h to meet the requirements of the course. Modified by T. Anastasio on 11 August 1999 Edit 1 Feb 2001 DLF for g++, include .C file */ #ifndef _VECTOR_H #define _VECTOR_H #define vector Vector class ArrayIndexOutOfBounds { }; template class vector { public: explicit vector( int theSize = 0 ) : currentSize( theSize ) { objects = new Object[ currentSize ]; } vector( const vector & rhs ) : objects( NULL ) { operator=( rhs ); } ~vector( ) { delete [ ] objects; } int size( ) const { return currentSize; } Object & operator[]( int index ) { #ifndef NO_CHECK if( index < 0 || index >= currentSize ) throw ArrayIndexOutOfBounds( ); #endif return objects[ index ]; } const Object & operator[]( int index ) const { #ifndef NO_CHECK if( index < 0 || index >= currentSize ) throw ArrayIndexOutOfBounds( ); #endif return objects[ index ]; } const vector & operator = ( const vector & rhs ); void resize( int newSize ); private: int currentSize; Object * objects; }; #include "vector.C" #endif