My + operator changing the value of my class
const Polynomial operator +(const Polynomial lhs, const Polynomial rhs){
//lhs is 1
Polynomial result(lhs);
result+=rhs;
//when I add rhs to my result it also increments my lhs and lhs is
now 3
cout<<"item: "<<rhs<<endl;
return result;
}
int size;
Monomial *polynome; // my polynome is an array of monomials
//p[0]= 2, p[1]=3x etc.
I am using default copy constructor(i didnt define one) maybe thats the
problem since I have a pointer to array I dont know. I rather not to share
my += operator unles necessary since it seem like its working fine but its
terribly implemented it would take 30 minutes to explain whats going on.
This is driving me crazy, any solutions?