I have an assignment dealing with polynomials and adding two of them together. Am using vectors to approach this and i have one vector assigned for coefficients and the other exponents
Am very very new to c++ and am at a lost.
Here is my + operator
Polynomial operator+(Polynomial& p1, Polynomial& p2);
{
Polynomial p3;
double sum;
vector<double>::const_iterator iter;
iter = coef.begin();
vector<int>::const_iterator iter2;
iter2 = expo.begin();
vector<double>::const_iterator iter3;
iter3 = p2.coef.begin();
vector<int>::const_iterator iter4;
iter4 = p2.expo.begin();
for (i = 0; i<coef.size(); i++)
if (*iter2 = *iter4)
sum =
return p3;
}
i don't know if what am doing is right or how to add 2 elements in a vector together after making sure the p1 and p2 exponents are equal. Please any help is appreciated