Weird problem with overloading
I just recently started getting a syntax error with my = operator and my copy constructor, but I don't even call the copy constructor in my program. here's the relevant code:
[code]
Code:
//struct that contains the coefficient and exponent of each term
struct term
{
int co; //coefficient
int exp; //exponent
term* link;
};
typedef term* termptr;
//class that contains the head of the list
class Polynomial
{
public:
Polynomial(Polynomial& p1);
~Polynomial();
Polynomial() {head = NULL;}
void operator = (Polynomial& p1);
Polynomial operator + (Polynomial& p1);
termptr get_head() {return head;}
void set_head(termptr t1) {head = t1;}
friend istream& operator >> (istream& ins, Polynomial& p1);
friend ostream& operator << (ostream& outs, Polynomial& p1);
private:
termptr head;
};
//I'm not gonna list the definitions because I don't think they're relevant plus some of them are quite long
//here's my application file
int main()
{
Polynomial p1, p2, result;
cout << //prompt
cin >> p1; // the >> operator is overloaded for lists
cout << //prompt
cin >> p2;
cout << endl;
result = p1 + p2;
cout << result;
return 0;
}
okay, here's the error I keep getting:
error: no matching function for call to 'Polynomial::Polynomial(Polynomial)'
note: candidates are: Polynomial::Polynomial(Polynomial&)
error: initializing argument 1 of 'void Polynomial::operator =(Polynomial&)'
I get the error on this line in my application file: result = p1 + p2;
I have tried everything I can think of, but I know it's something simple. help me out please