Polymorphism:- Polymorphism is one of the most important concept of Object Oriented programming.Polymorphism means function having same nam...
Polymorphism:-Polymorphism is one of the most important concept of Object Oriented programming.Polymorphism means function having same name but they have different data types and different number of argument.Or in simple words one name multiple form.The main feature of polymorphism is that it is used to perform single task with multiple name.This concept deals in C++,Java etc.
Polymorphism=Poly+Morph=Many Forms
Example of Polymorphism:-
char min(char,char)
{
....
....
}
int min(int,int,int,int)
{
....
....
}
char min(char,char,char)
{
....
....
}
x=min('a','b')
q=min(1,2,3,4)
z=min('p','q','r')
Type of Polymorphism:-
Function Overloading:-Function Overloading is a method of calling more than one function by the same name.
Operator Overloading:-Operator Overloading provides option for creation of new definition of Operators.
Some exception operators are:-
1)Scope Resolution Operator(::)
2)Sizeof operator
3)Conditional Operator(?:) etc.
Virtual Function:-When we used same function in both the child and parent class,than we apply virtual function in parent class.
Polymorphism=Poly+Morph=Many Forms
Example of Polymorphism:-
char min(char,char)
{
....
....
}
int min(int,int,int,int)
{
....
....
}
char min(char,char,char)
{
....
....
}
x=min('a','b')
q=min(1,2,3,4)
z=min('p','q','r')
Type of Polymorphism:-
Function Overloading:-Function Overloading is a method of calling more than one function by the same name.
Operator Overloading:-Operator Overloading provides option for creation of new definition of Operators.
Some exception operators are:-
1)Scope Resolution Operator(::)
2)Sizeof operator
3)Conditional Operator(?:) etc.
Virtual Function:-When we used same function in both the child and parent class,than we apply virtual function in parent class.
If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.
polymorphism in c++
ReplyDeleteGreat this is helpful for me.
Real life example of Polymorphism in C++
ReplyDeleteNice, keep sharing