#include <iostream.h>

const Max   = 20;
const True  =  1;
const False =  0;

template<class T> class Vector
{
  struct
  {
    T Data;                  //field Data is type T
    int Defined;             //field Defined is type int
  } Elements[Max];           //array of Max items

 public:
   Vector()
   //Creates an empty abstract array.
   {
     int Index;

      for (Index = 0; Index < Max; ++Index)
	Elements[Index].Defined = False;
   }

   void Init(T X)
   //Initialize all elements to X
   //Pre : Vector created and X defined.
   //Post: All elements set to X and marked as defined.
   {
     int Index;

     for (Index = 0; Index < Max; ++Index)
     {
       Elements[Index].Data = X;
       Elements[Index].Defined = True;
     }
   }

   void Store (T X, int I)
   //Stores X at position I in abstract array.
   //Pre : Vector created; X and I are defined.
   //Post: Elements[Index].Data is X and position I is defined.
   {
     Elements[I].Data = X;
     Elements[I].Defined = True;
   }

   void Retrieve(T &X, int I, int &Success)
   //Copies the value stored at vector position I to X.
   //
   //Post: Returns value stored at position I through X and
   //      set Success to True, if position defined; otherwise
   //      Success set to False.
   {
     Success = Elements[I].Defined;
     if (Success)
       X = Elements[I].Data;
   }

};
