Polymorphism
Polymorphism
1
Polymorphism – An Introduction
Polymorphism
Function Operator
Virtual Functions
Overloading Overloading
3
Run time Polymorphism – An Example
class shape
{
shape area() public:
void area();
};
We want the same function area() should calculate the area of all the
shapes depending upon the situation. 4
Run time Polymorphism – An Example
class shape { int main()
public: {
void area(); shape *sp;
};
◼ Declare
virtual function prototype = 0;
Ex: virtual area()=0;