Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. void LinkedList::copy(const LinkedList& other)
  2. {
  3. Node* temp = other.head;
  4. if (temp != nullptr)
  5. {
  6. ++n;
  7. Node* localTemp = head = new Node(temp->data);
  8. while (temp->next)
  9. {
  10. localTemp->next = new Node(temp->next->data);
  11. ++n;
  12. temp = temp->next;
  13. localTemp = localTemp->next;
  14. }
  15. }
  16. else
  17. head = nullptr;
  18. }
  19.  
  20.  
  21.  
  22.  
  23. void Queue::copy(const Queue& other)
  24. {
  25. for (Node* temp = other.head; temp; temp = temp->next)
  26. addBack(temp->data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement