A
ankyhe
I overload ==, >, <, >=, <=successfully, however I can't overload != .
How to overload operator !=?
How to overload operator !=?
I overload ==, >, <, >=, <=successfully, however I can't overload != .
How to overload operator !=?
Overloading "==" should do it
!= is a defined using == i.e. a != b is parsed as !(a == b)
that means: 1. you cannot override !=, 2. you have to override ==
Which is precisely what I meant
I overload ==, >, <, >=, <=successfully, however I can't overload != .
How to overload operator !=?
And upon reflection, this makes sense, as in any sane world !(f1 == f2)
will equal (f1 != f2), and so redefining != would be redundant.
Robert said:It's been a long day and I'm not sure whether my logic fails me here,
but - from the above seems to follow that C++ is potentially insane.
Not that I didn't know that before - but it's a nice outcome of a
thread about operators.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.