next up previous contents
Next: The Overloaded Equal: Up: The CHAR_SLLIST Implementation Details: Previous: The print and grab

The Constructors:

    // ********************************************** //
    // default constructor for CHAR_SLLIST class      //
    // ********************************************** //
 
CHAR_SLLIST::CHAR_SLLIST(char *name_in)
{
  name = new char[strlen(name_in)+1];
  strcpy(name,name_in);

  head = NULL;
}

     // ******************************************** //
     // copy constructor for CHAR_SLLIST class       //
     // ******************************************** //
 
CHAR_SLLIST::CHAR_SLLIST(CHAR_SLLIST& A)
{
  CHAR_SL_CELL *temp,*again;
  
  name = new char[strlen(A.name)+1];
  strcpy(name,A.name);

  if(!(A.head==NULL)){
    head = new CHAR_SL_CELL(name);
    head->element = A.head->element;
    temp = head;
    again = A.head->next;
    while(!(again==NULL)){
      temp->next = new CHAR_SL_CELL(name);
      temp->next->element = again->element;
      again = again->next;
      temp = temp->next;
      }
    }
}



Jim Peterson
1999-04-22