What is polymorphism, what is it for, and how is it used?
I've provided a high-level overview of polymorphism for another question:
Polymorphism in c++
Hope it helps. An extract...
...it helps to start from a simple test for it and definition of [polymorphism]. Consider the code:
Type1 x;
Type2 y;
f(x);
f(y);
Here,
f()
is to perform some operation and is being given the valuesx
andy
as inputs. To be polymorphic,f()
must be able to operate with values of at least two distinct types (e.g.int
anddouble
), finding and executing type-appropriate code.
( continued at Polymorphism in c++ )