August 2012
Intermediate to advanced
976 pages
30h 17m
English
When you design a class, you should always think first about what operations the class will provide. Only after you know what operations are needed should you think about whether to define each operation as an ordinary function or as an overloaded operator. Those operations with a logical mapping to an operator are good candidates for defining as overloaded operators:
• If the class does IO, define the shift operators to be consistent with how IO is done for the built-in types.
• If the class has an operation to test for equality, define operator==. If the class has operator==, it should usually have operator!= as well.
• If the class has a single, natural ordering operation, define ...
Read now
Unlock full access