I'm doing a full rewrite of an old library, and I'm not sure how to handle this situation (for the sake of being understood, all hail the bike analogy):
I have the following classes:
TBike
- the bike itselfTBikeWheel
- one of the bike's wheelTBikeWheelFront
and TBikeWheelBack
, both inherits from TBikeWheel
and then implements the specific stuff they need on top of itThis is pretty straightforward, but now I decide to create multiple kind of bikes, each bikes having it's own kinds of wheel - they do the same stuff as a regular front/back wheels, plus the specific for that bike.
TBikeXYZ
- inherits from TBike
TBikeWheelXYZ
- inherits from TBikeWheel
And here is my problem: TBikeWheelFrontXYZ
should inherit from TBikeWheelXYZ
(to get the specific methods of an XYZ wheel), but it should also inherit from TBikeWheelFront
(to get the specific methods of a front wheel).
My question here is, how can I implement that in a way that doesn't:
Delphi does not support Multiple Inheritance. But classes can support / implement multiple interfaces and you can delegate interface implementation, so you can kinda simulate multiple inheritence.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With