I am trying to loop through a polynomial using the iterator from the STL but it says i am dereferencing the iterator somewhere but i can not spot it. I have pin pointed the error to the return of the following code.
Polynom& Polynom :: AddPoly( const Polynom &a)
{
list<PolyTerm>::const_iterator i = a.getHead();
PolyTerm temp;
for( i = a.getHead(); i != a.getTail(); ++i)
{
temp.Coeff = i->Coeff;
temp.Exponent = i->Exponent;
addTerm(temp);
}
return *this;
}
addTerm is a function that adds the passed term to the list.
Polyterm is a struct with Coeff and Exponent as members.