PDA

View Full Version : What is polymorphism in c++ 2011



saneha
04-29-2011, 07:57 AM
What is polymorphism in c++ 2011

Vuhelper
04-29-2011, 07:58 AM
Polymorphism can be defined as “single interface multiple behaviour. Poly mean many morph means shapes, so one function taking many shapes. There are two types of polymorphism namely, runtime polymorphism and compile time polymorphism. Compile time polymorphism means functions overloading and run time polymorphism means virtual functions.
Example:
Given a base class shape, polymorphism enables the programmer to define different area methods for nay number of derived classes, such as circles, rectangles and triangles. No matter what shape an object is, applying the area method to it will return the correct result.