In Delphi, the answer is yes.
For instance, I have created a syntax-highlighting text editor component. This component has a property FormattingProcessor
, which is of type TFormattingProcessor
. Now, I have created several formatting processors, e.g. TXMLFormattingProcessor
, TPascalFormattingProcessor
, and TINIFormattingProcessor
, each class being a child of TFormattingProcessor
. Any of these can be assigned to the FormattingProcessor
property of the text editor component.
That is, the variable declared as TFormattingProcessor
can be assinged a value of type TXMLFormattingProcessor
, TPascalFormattingProcessor
, or TINIFormattingProcessor
, for instance.
If you look around in the VCL, you see that this type of assignments are actually very common. For instance, the TLabel
component has a FocusControl
property, which is of type TWinControl
(if I recall correctly). You can assign any decendant of TWinControl
to this property, e.g. a TEdit
. (The FocusControl is the control that will obtain keyboard focus when the accelerator character of the label is typed together with the Alt key.)