Hi,
I have two classes in a library (can't be changed) named "LibBase" and "LibChild". I have three classes that I am writing named "AppBase", "AppChild1", "AppChild2".
Other classes need "AppBase" to be treatable like a "LibBase", yet this class is instantiated through "AppChild1" and "AppChild2", which provide special implementations.
Consequently, I have organized the classes into the following structure:
LibBase
|
______|_____
| |
| |
v v
AppBase LibChild
| |
______|_____ ____|
| | |
| | |
v v v
AppChild1 AppChild2
This is the classic "diamond" multiple inheritance problem. Unfortunately, "LibChild" is not virtually inherited from "LibBase". There's also the added complication of "AppChild1".
To clarify the behavior I want:
- Instantiations of "AppChild1" and "AppChild2" to be treatable as instances of "AppBase"
- Instantiations of "AppChild1" and "AppChild2" to be treatable as instances of "LibBase"
- When constructed, "AppChild1" constructs "LibBase" through "AppBase"
- When constructed, "AppChild2" constructs "LibBase" through "LibChild"
Once again, the code in the libraries ("LibBase", "LibChild") is immutable, and no virtual inheritance is used in them.
I don't really know what to do here--I think I'm stuck. I am not a C++ expert, so I'm hoping that I'm just not seeing a solution that's there or that someone can show that it's not solvable. Any suggestions?
Thanks,
-G