CPP Language / PolymorphismPoly means many, morphism means forms. It means a function take more than one form in terms of number of arguments and their data types.Examples sum(int x, int y) sum(int x, float y) sum(int x, float y, double z) Types of polymorphism 1. Compile time / static / early binding Polymorphism. 2. Runtime / dynamic / late binding Polymorphism. Compile time Polymorphism If a call to a function is determined during compile time that’s why it is called compile time polymorphism. Example of Compile time Polymorphism are Function overloading and Operator overloading. Compile time Polymorphism Example
Runtime Polymorphism If a call to the function is determined at runtime that’s why it is called runtime polymorphism. Example of runtime time Polymorphism is function. Function Overriding Parent function is overrides by Child function..The function call determines at runtime determines to call which function (Child / parent function)is called runtime polymorphism.
|