Hi, everyone,

I overloaded 3 opearators in my Polynomial class, they are

"*" which returns the product of two polynomials, return type is Polynomial.

"+" which return the sum of two polynomials, return type is Polynomial.

"=" which makes the left side have a deep copy of the right side.

But if I write sum = poly1 + poly2; in the main driver, the compiler gives me error saying illegle operand, i think it's for the "=" operand.

If I get rid of +poly2, leaving sum = poly1, it works fine. I dont know why. The + sign should perform first, return a Polynomial object, and then the = operator make a deep copy of the return object to the left side sum.

So how can I make sum = poly1 + poly2 to work? Thanks for the helps.

Here is the code of the overloaded "="

Code:Polynomial & Polynomial :: operator = (Polynomial & rightSide) { if(head != NULL) // Empty the left side Polynomial frist if it's not empty { for(int i = 0; i < totalTerms; i++) deleteFirstNode(head); } rightSide.current = rightSide.head; for(int i = 0; i < rightSide.totalTerms; i++) // Make deep copy, create a copy of the linked list { (*this).addTerm(rightSide.current -> getCOEF(), rightSide.current -> getEXP()); rightSide.current = rightSide.current -> getLink(); } return *this; }