Browse - programming tips - c++ make a less than or equal operator from existing operatorsDate: 2010feb26 Language: C/C++ Q. Can I make a <= operator from existing < and == operators in my class? A. Yes, like this: bool operator<=(const MyClass &b) const { return operator<(b) || operator==(b); } bool operator>=(const MyClass &b) const { return operator>(b) || operator==(b); } I think it would be cool of C++ made this automatically for you.
Add a commentSign in to add a comment |