Sunday, 8 April 2018


Polymorphism is one of the crucial features of oop. It is simply means 'one name , multiple forms'. Any operation may exhibit different behaviours in different instances.


The ability to take more than one form is known as polymorphism. An operation may exhibit different behaviors in different instances.

Ex: Consider the operation of addition , for two numbers , the operation will generate a sum. If two operands are strings then the operation would produce a third string by concatenation.

Types of polymorphism:
 1. Compiler time polymorphism or Early Binding or Static BInding
 2. Run time polymorphism or Late Binding or dynamic Binding

Compile Time Polymorphism
 1. Selecting a function in normal way during compilation time is known as compile time polymorphism or static binding.

 2. During compilation time , the cpp compiler determines which function is used , based on parameters passed to the function.

 3. Static binding is achieved by using function overloading and operator overloading.

 4. Overloading refers to the same thing for different purpose , in function overloading. We can use the same function name to perform variety of task.

double volume (double l, double b, double h )
double volume(double r, double h)
void main( )
cout<<"\n\tVolume of the box is→"<<volume(1.2,2.2,3.4);
cout<<"\n\tVolume of the cylinder is→"<<volume(1.2,4.2);
getch( );

Volume of the box is→8.976
Volume of the cylinder is→18.99072

Run Time Polymorphism

 . In some situation, where the function name and the prototype is the same in both the base and derived classes, since the prototype of function is the same in both the places, the function is not overloaded and therefore static binding does not apply.

2. In such cases , the appropriate member function is selected while program is running and this is known as run time polymorphism.

3. Virtual function is used to achieve run time polymorphism.

4. At run time , when it known what class objects are  under consideration the appropriate function is done dynamically at run time.

5. Dynamic binding requires the use of pointers to objects.

1 comment:

Codecademy Code Foundations

Popular Posts


Android (23) AngularJS (1) Assembly Language (2) Books (10) C (75) C# (12) C++ (81) Course (1) Data Strucures (4) Downloads (1) Engineering (13) flutter (1) FPL (17) Hadoop (1) HTML&CSS (38) IS (25) Java (89) Leet Code (4) Pandas (1) PHP (20) Projects (17) Python (274) R (69) Selenium Webdriver (2) Software (14) SQL (27)