Polymorphism
I think polymorphism is:
-
Objects may respond differently to the same message.
-
Response is a function of the "state" of the object.
-
Response may also be a function of the "state" of another object.
-
During instantiation, the constructor(s) can produce different flavors
of the same object.
For the nerds:
-
Constructors can be overloaded.
Also true, but not polymorphism is:
For the nerds:
-
Inheritance extends a class resulting in new properties (see
inheritance)
-
Methods (other than constructors) can be overloaded (but not operators).
The Incredible Machine demonstration
-
By changing the state of the a machine (e.g. the orientation of
a kettle) different behavior ensues.
-
By changing global variables (e.g. gravity) machines behave differently.
J. Anthony Parker, MD, PhD, Tony_Parker@bih.harvard.edu