Possible Duplicate:
Generating Structures dynamically at compile time
I am now facing a situation where I want a derived class to inherit from either Base1
or Base2
depending on a condition (in C++03). This means, I want to implement something like:
// pseudo-C++ code
class Derived : public
if(condition) Base1 // inherit from Base1, if condition is true
else Base2 // else inherit from Base2
{ /* */ };
This is likely not a good design, but the real world is not perfect.
I have searched here for an answer, but I do not want to use a preprocessor directive Problems with ifdef based inheritance in C++.
How else could I achieve this?