Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. ListOfEmployee& ListOfEmployee::operator=(const ListOfEmployee& list) {
  2. EmployeeNode* copy = NULL;
  3. EmployeeNode* origin = list.head;
  4. if (this != &list) { // If lhs and rhs are not equal
  5. while (head != NULL) { //While head of lhs != null
  6. deleteMostRecent();
  7. }
  8.  
  9. while (origin != NULL) { // if temp val of rhs is not null
  10. if (head == NULL) { // if head of lhs is not is null do following
  11. head = copy = new EmployeeNode(Employee(origin->getEmp())); // make head(lhs) and copy(lhs) vals both equal to val in origin(rhs)
  12. }
  13. else {
  14. copy->setNext(new EmployeeNode(Employee(origin->getEmp()))); //set the next val of the copy node to current val stored in origin
  15. copy = copy->getNext(); //copy becomes equal to copys next val
  16. }
  17. origin = origin->getNext(); //origin becomes equal to its next va;
  18. }
  19. }
  20. return *this; // return lhs
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement