next up previous contents
Next: The Overloaded Equal: Up: Overloaded I/O Methods: Previous: Using the Iterators:

The Constructors:

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

  head = NULL;
  end = NULL;
  //head = new CHAR_DL_CELL(name);
  //end = head;
}

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

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



Jim Peterson
1999-04-22