I am trying to overload the * operator to multiply two objects of my class. Since it is a binary operator I know that the function should take a LHS and a RHS parameter. However, when I try the following, I get a compiler error saying :
`Polynomial Polynomial:: operator*(Polynomial, Polynomial)' must take either zero or one argument
When I give it only one parameter, then it compiles. But unless I am mistaken, then it will not be able to actually multiply two polynomials. Thanks in advance.Code:class Polynomial { public: Polynomial operator*(Polynomial a, Polynomial b);



LinkBack URL
About LinkBacks



then you should also have operator*= (or operator+=, -=, /=, %=). Then, a good way to implement operator* would be to create a temporary copy of the left hand side object, then use operator*= on it with the right hand side object and return the result.