August 2012
Intermediate to advanced
976 pages
30h 17m
English
Classes for which the equality operator is defined also often (but not always) have relational operators. In particular, because the associative containers and some of the algorithms use the less-than operator, it can be useful to define an operator<.
Ordinarily the relational operators should
1. Define an ordering relation that is consistent with the requirements for use as a key to an associative container (§ 11.2.2, p. 424); and
2. Define a relation that is consistent with == if the class has both operators. In particular, if two objects are !=, then one object should be < the other.
Although we might think our ...
Read now
Unlock full access