/* This file contains the declaration of class Table.

...
------------------------------------------------------------------*/

// ... preprocessor directives omitted ...

typedef double TableElement;

class Row
{
public:
   enum {MaxLength = 20};                // maximum length of a Row

protected:
   TableElement                          // declare one-dim array 
      Array[MaxLength];                  //   of TableElements

public:
   TableElement& operator[] (unsigned j) // overload [] so that
      {return Array[j];}                 //  (Row)[j]accesses
                                         // element j of Row

   const TableElement& operator[] (unsigned j) const
      {return Array[j];}                 // for const objects
};


class Table
{
public:
   enum {MaxRows = 20,
         MaxCols = Row::MaxLength};      // define Table::MaxCols
                                         //   using length bound
                                         //   from Row
protected:
   Row                                   // restructure Grid as a
      Grid[MaxRows];                     //   one-dim array of Rows

   unsigned
      Rows_,
      Columns_;

public:
   Table(                                //  the class constructor
         unsigned RowVal = 0,            //    the number of rows
         unsigned ColVal = 0,            //    the number of columns
         TableElement InitValue = 0);    //    initialization value

   Row& operator[] (unsigned i)          //  overload [] so that T[i]
      {return Grid[i];}                  //    accesses Row i of Grid

   const Row& operator[] (unsigned i) const
      {return Grid[i];}                  // for const objects

   // ... remaining members of Table omitted ...
};

