Sorry to bombard you guys with questions. I'm getting an error that seems to stem from overloading *= and I am stumped.
Here is the function:
1 2 3 4
|
void timesequals(multiset<Algebraic>& S, const Algebraic& x)
{
multiset<Algebraic>::iterator i;
for(i = S.begin(); i != S.end(); i++)
|
} |
The problem seems to involve *= (which normally works fine). Its declaration is:
|
Algebraic& Algebraic::operator *=(const Algebraic& s);
|
Algebraic is a class I defined, presumably the definition is not relevent. Now when I compile, here is the error:
g++ -c -I. -I/opt/local/include -I/usr/local/include -g algebraic.cc
algebraic.cc: In function ‘void timesequals(std::multiset<Algebraic, std::less<Algebraic>, std::allocator<Algebraic> >&, const Algebraic&)’:
algebraic.cc:1207: error: passing ‘const Algebraic’ as ‘this’ argument of ‘Algebraic& Algebraic::operator*=(const Algebraic&)’ discards qualifiers
Line 1207 is the one the arrow is pointing to in the first code fragment.
Any idea what is wrong? The compiler seems to think S is a const...
EDIT: Probably *= is fine, but the compiler doesn't want me to access directly the elements of a multiset because it is worried I may screw up the order. Is it possible to override this behavior?