1: // Created by Frank M. Carrano and Tim Henry.
2: // Copyright (c) 2013 __Pearson Education__. All rights reserved.
4: // Interlude 5, pp 418 - 419.
6: template <class ItemType>
7: LinkedList<ItemType>& LinkedList<ItemType>::operator=(const LinkedList<ItemType>& rightHandSide)
8: {
9: // Check for assignment to self
10: if (this != &rightHandSide)
11: {
12: this->clear(); // Deallocate left-hand side
13: headPtr = copyListNodes(rightHandSide); // Copy list nodes
14: itemCount = rightHandSide.itemCount; // Copy size of list
15: } // end if
16:
17: return *this;
18: } // end operator=