Productivity Hint 17.2
Define Comparisons in Terms of Each Other
- Write 1 or 2 member functions; equality, and strict inequality
- Define all comparisons in terms of these functions
- E.g.: Fraction class (fraction.cpp)
- A single compare method (line 97), returns an
int
- All 6 comparison operators (lines 104-132) call compare
prev
|top
|next