Polymorphism
⚫ The term Polymorphism gets derived from the Greek word where poly + morphos
⚫ Poly means “many”
Where
⚫ Morphos mens “forms”
⚫ Static (Compile-Time) Polymorphism
Types
⚫ Dynamic (Run-Time) Polymorphism
Static Polymorphism
⚫ The type of polymorphism in which the compiler knows at compile time which function to be
called
⚫ The function definition is bounded to the function call at compile time
⚫ Memory is allocated at compile time
⚫ Function Overloading
Implementations/Examples
⚫ Operator Overloading
Dynamic Polymorphism
⚫ The type of polymorphism in which the compiler knows at run time which function to be called
⚫ The function definition is bounded to the function call at run time
⚫ Memory is allocated at run time
Implementation/Examples
⚫ Virtual Function(function overriding)
Differences b/w compile time and run time polymorphism
Muhammad Farooq GPGC Swabi
, Page | 2
Pointer to Objects
⚫ Pointers are used to access members of the objects
Syntax
p -> member;
Where
p: is pointer
->: member access operator
Pointers & Inheritance (Only Base pointer)
Muhammad Farooq GPGC Swabi