Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 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. for (Node* localTemp = head = new Node(temp->data); temp->next; temp = temp->next, localTemp = localTemp->next, ++n)
  16. localTemp->next = new Node(temp->next->data);
  17. }
  18. else
  19. head = nullptr;
  20. }
  21.  
  22.  
  23.  
  24.  
  25. void Queue::copy(const Queue& other)
  26. {
  27. for (Node* temp = other.head; temp; temp = temp->next)
  28. addBack(temp->data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement