Polymorphic variables

We have used the idea of a polymorphic variable several times already in this book. We have noted in earlier chapters how an instance of a class can, in fact, be holding a value from a subclass type.

In most strongly typed languages, the dynamic or run-time type must be a subclass of the static (or compile time type).

In C++ this works only with pointers and references.

In Java, polymorphic variables can also be constructed from Interface types.

However it is formed, the polymorphic variable or value is the basis for much of the power of object-oriented techniques.

[audio] [real] Text to accompany slide6, in Chapter 14 of An Introduction to Object-Oriented Programming