I've been writing a polynomial class and I was overloading operators for it. I managed to (I think) successfully overload the += operator and now I created an external function that uses += for addition just like advised in many sources. It works but I can't chain them for some reason When I try to add polynomials like this
poly a, b, c, d;
a=b+c+d;
I get an error: no matching function for call to 'poly::poly(const poly)'
My += function's main body isn't all that important but that's what it's like:
poly& operator+= (const poly& a){
//implemented +=
return *this;
}
My addition function (outside of the class) looks like this:
const poly operator+ (poly a, const poly & b){
a+= b;
return a;
}
What am I doing wrong here?