The term polymorphism was derived from the Greek words `poly` and `morphos`, which mean `many` and `forms`, respectively. In OOP, polymorphism is often expressed by the phrase "one interface, multiple functions". This expression means that polymorphism allows one interface to be used for multiple functions.
Polymorphism can be applied for reducing the complexity within the functions of a class of your program.
Static polymorphism refers to an entity, which exists in various forms simultaneously. The concept of a static polymorphism is analogous to the role of a woman who can be a wife, a mother, a daughter, a sister, and an executive at the same time.
The mechanism of linking a function with an object during compile time is called early binding. This process is also known as static binding. C sharp uses two approaches to implement static polymorphism, these are Function overloading and operator overloading.
Function overloading approach allows using the same name for two or more functions. Each redefinition of a function must use different types of parameters, sequence of parameters, or a number of parameters.
The type, sequence, or a number of parameters for a function is called the function signature. When you have multiple functions with the same name, the compiler identifies the function based on the parameters to the function. Compiler is used to compile or run a given program.
It converts the program to machine understandable language and executes it. If an error occurs while executing the program then output is displayed on the display showing the error.
To understand the benefit of function overloading where you need a function that converts distance in kilometers to miles, and kilometers can either be an integer or float. One approach can be to have two functions of different names.
Another approach can be using function overloading. Two functions with the same name but with different parameters.
Operator overloading allows user-defined types such as structures and classes.
For easy manipulation of the objects users can use overloaded operators. Operator overloading can be achieved by defining the static member function using the operator keyword.
Quick Note: Taking the Nonsense out of looking for the right spyware remover
If you really want to take the work out of looking for that right Spyware Protection from a go to the Internet and get a or a Free
Download, In order to prevent your vital information from being ripped from your computer get your Remover Today.
In dynamic polymorphism the decision about function execution is made at runtime. Dynamic polymorphism is more useful as compared to static polymorphism because dynamic polymorphism gives much more flexibility for manipulating objects.
The mechanism of linking a function with an object at runtime is called dynamic or late binding. Dynamic binding supports virtual function.