Re: template operator== not working
Thanks Alexander for your reply.
The use of const on the return comes from Scott Meyers' Effective C++
Third Edition Item 3
"const Rational operator*(const Rational& lhs, const Rational& rhs);
Many programmers squint when they first see this. Why should the
result of operator* be a const object? Because if it weren't, clents
would be able to commit atrocities like this:
Rational a, b, c;
...
(a * b) = c; // invoke operator= on the result of a*b!
..."
You might not see that example as typed but if( a * b = c) ... does
occure because of typing mistakes. The compiler will catch this.
Now this might not apply to the operator== but it is a practice I've
picked up and just haven't changed.
Good enough. It's not that const in the return type is wrong -- it
certainly isn't, and Scott makes a very good argument for including it -- it
just isn't necessary for correct usage of the operator to work. On the
other hand making the function const is necessary, otherwise the compiler
will throw errors when you test for equality with a const reference.
Thanks again
Mark