Object oriented programming concepts-Session 7
Object oriented programming concepts-Session 7
nl
O
se
U
tre
en
Session: 7 C
h
ec
Overloading
pt
rA
Fo
O
se
List the different forms of Overloading
U
Explain Method Overloading
tre
en
Explain Constructor Overloading
C
h
Explain Operator Overloading
ec
pt
rA
Fo
se
function can be implemented in several ways
U
tre
en
Meaning or behavior of a function or method can be
changed based on the context in which it is used
C
h
ec
pt
O
name can have several implementations by changing
se
its signature.
U
tre
Changing the signature involves change in:
en
Number of parameters
C
h
Type of parameters
ec
Sequence of parameters
pt
rA
Fo
se
same name but with different parameters.
U
tre
The advantage is that it allows methods with similar
en
functionality to be used by a common name.
C
h
ec
pt
O
different arguments
se
U
tre
en
C
To initialize selected members only, it is required
h
ec
O
an existing operator to allow them to be used with
se
user-defined types.
U
tre
It is used to:
en
Add the values of two vectors or two complex numbers
C
Multiply matrices or non-arithmetic functions
h
ec
O
operator behaves when used with his own class and
se
other data types.
U
Syntax
tre
en
public static <result-type>
operator <operator> (op-type1
operand1, op-type2 operand2)
C
h
ec
{
pt
// processing statements
rA
}
Fo
O
name can have several implementations by changing the
se
number, type, or sequence of parameters.
U
A method in which only the return type or the names of the
tre
parameters have been changed cannot be considered
overloaded.
en
C
A constructor is a special method that has the same name as the
class name and is used to initialize the data members of the
h
ec
class.
pt
O
overloading in C#.
se
Operator overloading enables a user to convert data to and from
U
one type to another.
tre
Operator overloading enables a user to perform arithmetic and
en
logical operations on a type with itself or other types.
C
h
ec
pt
rA
Fo