Given the following stub-definition for the assignment operation:
List& List::operator=(const List& rhs) { // rhs == right hand side
}
one way to implement the operation is using the following steps:
Rather than copy-and-paste the copy constructor's logic into your assignment operator (propagating any logic errors it might contain), consider highlighting the body of the copy constructor and then using Eclipse's Refactor > Extract function mechanism to extract the body of the copy constructor into a method named makeCopyOf(). Eclipse will create a new method containing the code you've highlighted, and then replace the highlighted code with a call to that new method. You can then invoke that new method in your assignment operator (passing it rhs as an argument) to perform steps 1.b, 1.c, 1.d, and 1.e, greatly simplifying your assignment operation.