Guest User

Untitled

a guest
Aug 20th, 2019
64
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 91 IntList& IntList::operator=(const IntList& source){
  2. 92 //deep copy version
  3. 93 Node* n = new Node;
  4. 94 Node* p = source.first;
  5. 95 IntList* list = new IntList;
  6. 96 list->first = n;
  7. 97 while(p) {
  8. 98 if (!n) {
  9. 99 Node* s = new Node;
  10. 100 s->info = p->info;
  11. 101 n = s;
  12. 102 } else {
  13. 103 n->info = p->info;
  14. 104 }
  15. 105 n = n->next;
  16. 106 p = p->next;
  17. 107 }
  18. 108 return *list;
  19. 109 }
RAW Paste Data