Question: Need help with this. How to make implementation of assignment operator, please help.//Copy Constructor: Make DEEP copy SortListClass::SortListClass(const SortListClass& existingList): size(existingList.size) {if (existingList.head -= NULL)

Need help with this.  Need help with this. How to make implementation of assignment operator,

How to make implementation of assignment operator, please help.//Copy Constructor: Make DEEP copy SortListClass::SortListClass(const SortListClass& existingList): size(existingList.size) {if (existingList.head -= NULL) head = NULL;//original list is empty else {//copy first node head = new SortListNode; assert (head != NULL);//check allocation head rightarrow item existingList.head rightarrow item;//copy rest of list SortListNode *newPtr - head;/ew list pointer/ewPtr points to last node in new list//origPtr points to nodes in original list for (SortListNode *origPtr existingList.head rightarrow next; origPtr ! = NULL; origPtr = origPir rightarrow next) {newPtr rightarrow next = new SortListNode;//link new node to end of list assert(newPtr rightarrow next; = NULL); newPtr = newPtr rightarrow next; newPtr rightarrow item = origPtr rightarrow item;//copy the data newPtr rightarrow next = NULL;}}//retum(*this);}/*//assignment operator Make DEEPcopy SortListClass& SortListClass::operator=(const SortListClass& rhs) {//TODO//Similar to Copy Constructor, except//- Avoid self-assignments such as "X = X;"//- Delete existing this-instance content before//making this-instance a copy of the rhs instance return(*this);}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!