English
Topic 9. Operator overloading and friend functions
Goal: learn to apply the concepts of the topic “Operator Overloading and Friend Functions” in console projects; justify the invariants and the contract of operators, and test ordinary and edge cases.
Lecture contents
- Operators as an interface — An operator as part of the interface · Arithmetic, symmetry and compound operators
- Indexing, calls and increment — Indexing and choosing semantics · Calling an object and increment
- Comparison, friends and streams — Comparison and ordering categories · Friend functions and hidden friends · Stream input without partial state · Assignment, arrow and the limits of convenience
- Case studies and common mistakes — Tests of algebraic properties · Designing operators for a temperature and a temperature difference · Consistency of equality, ordering and normalization · A table of operator interface tests · An interval contract: An operator doesn’t always return the same type · Why conversions are better made explicit · Two levels of testing a stream operator