#include using namespace std; const short kNumElements = 10; //--------------------------------------- Array template class Array { private: short arraySize; T *arrayPtr; T errorRetValue; public: Array( short size ); ~Array(); T &operator[]( short index ); }; template Array::Array( short size ) { arraySize = size; arrayPtr = new T[ size ]; errorRetValue = 0; } template Array::~Array() { delete [] arrayPtr; } template T &Array::operator[]( short index ) { if ( ( index < 0 ) || ( index >= arraySize ) ) { cout << "index out of bounds(" << index << ")\n"; return( errorRetValue ); } else return( arrayPtr[ index ] ); } //--------------------------------------- Power template T Power( T base, T exponent ) { T i, product = 1; for ( i=1; i<=exponent; i++ ) product *= base; return( product ); } //--------------------------------------- main() int main() { Array myRay( kNumElements ); Array myLongRay( kNumElements ); short i, shortBase = 4; long longBase = 4L; for ( i=0; i<=kNumElements; i++ ) myRay[ i ] = Power( shortBase, i ); cout << "----\n"; for ( i=0; i