calling the class within the public...help!
I think this is a pretty simple problem, but I just can't get it, I have the following class:
Code:
class Polynomial
{
private:
int coeff[LEN];
public:
Polynomial ();
Polynomial Add (const Polynomial& P2) const;
Polynomial Subtract (const Polynomial& P2) const;
void Print (unsigned wid=0) const;
unsigned width () const;
void setCoeff (unsigned index, int newCoeff);
};
Polynomial::Polynomial()
{
for (unsigned i=0; i<LEN; i++)
{
coeff[i]=0;
}
}
I'm trying to implement the Add member but I can't figure out how to access what's in P2
I've tried
Code:
Polynomial Polynomial::Add (const Polynomial& P2) const
{
Polynomial Ptemp;
for (unsigned i=0; i<LEN; i++)
{
Ptemp = coeff[i] + P2[i];
}
return Ptemp;
}
and then it gives me complier error "no match for `Polynomial &[unsigned int &]'"
So I don't know really what to do, any help would be nice :)