Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //appends the deep copies of the nodes of rhs on to the end of this list
- void LinkedList::appendList(const LinkedList& rhs)
- {
- //Allocate new memory for a new node
- Node *tempNode;
- //The node is set to rhs head
- tempNode = rhs.head;
- //current node is set to tail by default
- Node *currentNode = tail;
- while (tempNode != nullptr)
- {
- //Allocate new memory for a new node
- Node *temp2 = new Node;
- //Copy over the value
- temp2->data = tempNode->data;
- //set the next node to the temp2 node
- currentNode->next = temp2;
- //set current node to the next node
- currentNode = currentNode->next;
- //set the temporary node to the next node
- tempNode = tempNode->next;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement