CPP Unit 4
CPP Unit 4
Operator Overloading
✓ A symbol that is used to perform an operation is called an operator. It is
used to perform an operation with constants and variables.
✓ A programmer cannot build an expression without an operator.
✓ The compiler knows how to perform various operations using operators
for the built-in types, however, for the objects those are instance of the
class, the operation routine must be defined by the programmer.
✓ Keyword operator - The keyword operator defines a new operation (or)
action to the operator.
✓ In C++, we can change the way operators work for user defined types like
objects and structures. This is known as operator overloading.
Polymorphism – Introduction
Polymorphism
✓ Polymorphism means the ability to take more than one form. Advantage
of this is you can make an object behave differently in different
situations, so that no need to create different objects for different
situations.
✓ Polymorphism can be achieved with the help of
✓ Overloading and Overriding concepts and it is classified into compile
time polymorphism and Runtime polymorphism.
✓ Function with same name but different arguments .
✓ Functioning is different.
✓ Example : add(int a, int b) add(int a, int b, int c)
add(float a, float b) add(float a, float b, float c)