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 if C++ made this automatically for you.
Programming Tips - Can I make a = operator from existing and == operators in my class?
Date: 2010feb26
Language: C/C++
Keywords: lessthan, greaterthan, equals
Q. Can I make a <= operator from existing < and == operators in my class?
A. Yes, like this: