August 2012
Intermediate to advanced
976 pages
30h 17m
English
Ordinarily, we “call” an overloaded operator function indirectly by using the operator on arguments of the appropriate type. However, we can also call an overloaded operator function directly in the same way that we call an ordinary function. We name the function and pass an appropriate number of arguments of the appropriate type:
// equivalent calls to a nonmember operator functiondata1 + data2; // normal expressionoperator+(data1, data2); // equivalent function call
These calls are equivalent: Both call the nonmember function operator+, passing data1 as the first argument and data2 as the second.
We call a member operator function explicitly in the same way that we call any other member ...
Read now
Unlock full access