In the first Classes (II) example of C++ tutorial, the code shows an operator being defined (lines 18-23). The example shows one Cvector parameter (Cvector param), but in the main () function, two added values are passed as a variable to c (c=a+b). How is the operator taking these two values if it only takes one parameter under the operator + definition?
Overloaded operators are just all other functions. Member operators have the this pointer as implicit argument.
Try to see if the following example helps:
first . operator+ ( second )
first . operator+ ( second )
first . m ( second )
operator- ( first, second )
operator- ( first, second )
f ( first, second )
Think + as a function called 'operator+' which can be called using a syntax which differs from normal function calls
I can't thank you enough for you detailed explanation. Finally understand it!!! The speed and efficiency of you explanation is second to none!!!! Thanks again!!!