What is polymorphism and how it can be implemented
In general, polymorphism means the ability to appear in several different forms. When it comes to OOP it gives an ability to process objects in different behavior depending on their data type or class. It provides some power to the child class that can redefine the methods. polymorphism is the main pillar of the OOP. If you consider the human mouth as a real-time example then its a best example, he can speak and he can eat so on.
Compile-time polymorphism
This mechanism can be implemented by function overloading or operator overloading.
Function overloading :
Function overloading is where you can implement more than one method or function with the same name but there will be differences in the signature in the other words the number arguments we pass should be different and also type of arguments.
Operator Overloading:
Operator overloading is where the plus operator is used to add the tow numbers and the same operator can be used for combining two strings.
One thought on “What is polymorphism and how it can be implemented”
Comments are closed.