CS202 6- ‹#›
Assignment Operator
nlist & list::operator = (const list & l) {
n  if (this == &l) return *this;   //why not *this == l?
n  //If there is a list, destroy it
n  node * current;
n  while (head) {
n    current = head->next;
n    delete head;
n    head = current;
n  }
n  if (!l.head)
n    head = ptr = tail = NULL;
n  else {
n    head = new node;
n    head->obj = l.head->obj;
n
n    node * dest = head;    //why are these local?
n    node * source = l.head;
n    while (source) {
n      dest->next = new node;
n      dest = dest->next;
n      dest->obj = source->obj;  //what is this doing?
n    }
n    dest->next = NULL;
n    tail = dest;  ptr = head;
n  }
n}
n
n