0

Hey everyone,

I'm very new to c++ and need some help with overloading operator= for a polynomial class. Here's my relevant code:

```
// i can't change the method signature as it is required this way
polynomial& polynomial::operator =(const polynomial& rtSide) {
this->nullify(); // a method to reset variables
polynomial result;
// the degree method returns the degree of the polynomial
// set coefficient method sets coefficient of the given exponent
for (int i = 0; i <= rtSide.degree(); i++)
result.setCoefficient(i, rtSide.coefficients.at(i));
return result;
}
```

the code in my main method

```
polynomial * polynomials = new polynomial[NUM_POLY]; // NUM_POLY = 5;
//initialize the polynomials
for (int i = 0; i < NUM_POLY; i++)
polynomials[i].nullify();
.
.
.
// the code before this builds up the polynomials based on user input from command line
int i = 1; int j = 0;
polynomials[i] = polynomials[j]; //this is not working for some reasons; the polynomials[i] remains the same as it is before but the line below works
//polynomial p = polynomials[j];
```

I'm new to this and can't seem to pin point the problem even after wasting more than 3 hours on this. I would really appreciate if someone can guide me to the solution, thanking in advance.