Listing 6 Non-inline member function definitions for a generic queue of common *

//
// comq6.cpp - generic queue of common *
// with an iterator class
//

#include "comq6.h"

common *comq::iterator::next()
   {
   common *pv = 0;
   if (pc != 0)
      {
      pv = pc->element;
      pc = pc->next;
      }
   return pv;
   }

void comq::append(const common &e)
   {
   cell *p = new cell(e, 0);
   if (first == 0)
      first = p;
   else
      last->next = p;
   last = p;
   }

void comq::clear()
   {
   cell *p;
   while (first != 0)
      {
      p = first;
      first = first->next;
      delete p;
      }
   last = 0;
   }

int comq::remove(common &e)
   {
   if (first == 0)
      return 0;
   cell *p = first;
   if ((first = first->next) == 0)
      last = 0;
   e = *p->element;
   delete p;
   return 1;
   }

// End of File