Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Operator Overloading
Each C++ operator has a predefined meaning.
Most of them are given additional meaning
through the concept called operator
overloading
Main idea behind Operator overloading is to use
C++ operators with the class objects.
Eg:
+ can be used to add 2 ints, floats or
doubles, the same + can be used to add 2
class objects, thereby + gets overloaded.
When an operator is overloaded, its original
op
Or
friend function.
The basic difference :
A friend function will have only one
argument for unary operators and two for
binary operators.
A member function has no arguments for
unary operators and one argument for
binary operators.
This is because the object used to invoke
the member function is passed implicitly
and therefore is available for the member
function.
Arguments may be passed either by value
or by reference.
original operators.
.*
Pointer-to-member operator
::
? ; Conditional operator
Membership operator