Listing 14 More Form member functions

// form.cpp

#include <assert.h>
#include "form.h"

int Form::add(Field *fp)
{
   assert(fp);
   if (nfields >= MAXFIELDS)
      return -1;

   fields[nfields] = fp;
   return nfields++;
}

Form::~Form()
{
   // Assumes fields are on heap
   for (int i = 0; i < nfields; ++i)
      delete fields[i];
}

// End of File