1. 23 November 2019 N.Nandhini AP/MCA 1
Operator overloading
What is Overloading?
Types of Overloading.
Operator Overloading.
Types of Operator Overloading.
2. 23 November 2019 N.Nandhini AP/MCA 2
What is Overloading?
Two Type is
1. Method Overloading
2. Operator Overloading
4. 23 November 2019 N.Nandhini AP/MCA 4
Cont..
Rules for Operator Overloading
Only Predefined Operator is Overloaded.
Cannot Change Operator Template.
Natural meaning and overloaded meaning is same.
Must have a user defined operand.
Types of Operator Overloading.
Unary Operator Overloading.
Binary Operator Overloading.
Syntax
modifiers type operator op(arglist)
{
Method body//task defined
}
7. 23 November 2019 N.Nandhini AP/MCA 7
Binary Operator Overloading
Binary Operators will work with two Operands. Examples of binary operators
include the Arithmetic Operators (+, -, *, /, %), Arithmetic Assignment operators
(+=, -+, *=, /+, %=) and Relational Operators etc. Overloading a binary operator
is similar to overloading a unary operator, except that a binary operator requires
an additional parameter.
8. 23 November 2019 N.Nandhini AP/MCA 8
Benefits of Operator Overloading :
1. Operator Overloading provides additional capabilities to
C# operators when they are applied to user-defined data
types.
2. Operators may be considered as functions internal to the
compiler.