Operator Overloading in c (1)
Operator Overloading in c (1)
The advantage of Operators overloading is to perform different operations on the same operand.
Operator that cannot be overloaded are as follows:
operator op is an operator function where op is the operator being overloaded, and the
operator is the keyword.
Rules for Operator Overloading
• Existing operators can only be overloaded, but the new operators cannot be
overloaded.
• The overloaded operator contains atleast one operand of the user-defined data
type.
• We cannot use friend function to overload certain operators. However, the
member function can be used to overload those operators.
• When unary operators are overloaded through a member function take no explicit
arguments, but, if they are overloaded by a friend function, takes one argument.
• When binary operators are overloaded through a member function takes one
explicit argument, and if they are overloaded through a friend function takes two
explicit arguments.