Thursday, January 29, 2004 07:42 AM
I'd say that composition is inherently much more "static" than composition, in the way you seem to be using the terms.
Composition can just be "member fields"; e.g. "A is composed of B and C" can be implemented by class A having member fields of type B and C (types known statically at compile time).
But inheritance is used in polymorphism, and you already decided earlier that polymorphism is "dynamic", according to your use of the term.
e.g. with polymorphism, you pass around parent type references, which can dynamically refer to objects of various different subtypes; the actual subtype, and consequently the actual overriden method call, can only be determined at runtime.