Describe Polymorphism in object oriented programming

Polymorphism refers to "one name but different forms"
– Polymorphism is implemented by function over loading and operator overloading
– Giving same name to functions with different no or types of arguments
– This information is known to compiler at compile time and compiler is able to select the appropriate function at call time
– It is called compile time polymorphism-Early binding.
# If appropriate member function are chooses at run time rather than compile time, this is
known as runtime polymorphism or Late binding.
# For this mechanism we chose member function as virtual.
In C++, polymorphism indicates the form of a member function that can be changed at runtime. Such member functions are called virtual functions and the corresponding class is called polymorphic class. The objects of the polymorphic class, address by pointers, change at runtime and respond differently for the same message. Such mechanism requires postponement of binding of a function call to the member function declared as virtual until runtime.


0 comments:

Feel free to contact the admin for any suggestions and help.