July 2000
Intermediate to advanced
1280 pages
34h 55m
English
As I mentioned in the previous chapter, any function related to any programmer-defined data type can be implemented either as a class member function or as a global stand-alone nonmember function. This is true of any algorithm, and this is true of overloaded operator functions. Switching from class member to nonmember implementation and back is an important programming skill. It is especially important for operator functions.
The operator can be defined as a member function of the class of its parameters. The number of parameters is one less than the arity of the operator (one for binary, none for unary). This absent parameter becomes the target of the message when the operator is used.
Read now
Unlock full access