What is Polymorphism in C++ ?
Polymorphism :- It allows a single name/operator to be associated with different operations depending on the type of data passed to it. In C++ it is achieved by function overlapping, operator overlapping and dynamic binding.
Example :- int sum (int a, int b) {return (a+b);}
float sum (float a, float b){ return (a+b);}
The observe two functions used to add two integers and two float. The function will be called depending on the arguments passed to it.
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment