Listing 3: Array and SubArray

template <typename T, unsigned int N>
class SubArray 
{  
   T * m_pElements; // Refers to elements in another Array
  
public:
  
   SubArray<T, N-1> operator [] (unsigned int index); 
   const SubArray<T, N-1>
   operator [] (unsigned int index) const; 
};

template <typename T, unsigned int N>
class Array 
{
   T * m_pArrayElements; // C array storing all Array elements
  
public:

   SubArray<T, N-1> operator [](unsigned int index); 
   const SubArray<T, N-1>
   operator [] (unsigned int index) const; 
};