C++ greater than or equal to operator

  • A+
Category:Languages

In C++, for the operator greater than or equal to (">="), is it enough to have the operators equal ("=") and greater (">") overloaded to have functionality for the greater than or equal to (">=")? Or do I need to overload the operator (">=") to have functionality for it?

 


Using an obvious notation, ">" || "==" is actually an over-requirement for ">=".

Although note that for all the relational operators, you only actually need "<", since equivalence is established if a < b and b < a are both false. In fact this is one of the concepts used in ordered C++ standard library containers.

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: