What is Polymorphism?Polymorphism: Poly – Multiple and Morph - Form- Polymorphism means the ability to take more than one form. An operation may exhibit different behavior in different instances. The behavior depends on the types of data used in the operation. For example, consider addition operation. For two numbers, the operation will generation sum. In case of two strings, it will generate a third string with concatenation. Thus, polymorphism allows objects with different internal structure to share same external interface. This means that a general class of operations can be accessed in the same manner even though specific actions associated with each operation may differ. - There are two types of polymorphism :
Compile Time Polymorphism : Achieved using operator overloading and function overloading
Rum Time Polymorphism : Achieved using virtual functions..
|