I have the following code in the private section of a basic Polynomial class .h file:
private:
struct Term
{
float coefficient;
int power; // power of specific term
};
int degree; //total number of terms
I have the following default constructor for the Polynomial class:
Polynomial::Polynomial()
{
Polynomial.Term poly;
poly.power = 0;
poly.coefficient = 0;
degree = 1;
}
I am confused on how to access the terms inside the struct as well as the variable outside the struct. I tried to google this, but couldn't find anything helpful.
Edit: overloaded output operator code
ostream & operator << (ostream & outs, Polynomial & P)
{
outs << P[0].poly.coefficient << "x^" << P[0].poly.power;
for (int i=1; i<P.degree-1; i++)
{
if (P[i].poly.coefficient > 0)
outs << "+";
outs << P[i].poly.coefficient << "x^" << P[i].poly.power;
}
outs << endl;
}
poly.from?Polynomial.TermDid this really compile?