02 / 09 / 2022

56. OOP Basics Part 3

For Polymorphism, it is further devided into 4 types. Ad-hoc Polymorphism allows functions having same name to act differently for different types which also known as Overloading.
Inclusion Polymorphism is the ability to use derived classes through base class pointers and references.** It is also known as Run-time polymorphism because the address of the function is not located by the Compiler at compile-time, rather, the right pointer from the virtual table is dereferenced to invoke the function at run-time. It is also known as Subtyping.
Coercion Polymorphism, which also known as Casting, occurs when an object or primitive is cast into some other type.** It could be either Implicit or Explicit.
Parametric Polymorphism opens a way to use the same piece of code for different types.** It is implemented by the use of Templates. It is also known as Early Binding.