I'm looking for a smart way of doing some sort of dynamical class inheritance.
This can best be explained with the psudo example below. Think of a base class to store information and smaller classes to display that information in different ways.
SetValues() are just a function to set values or whatever with the common variables, etc. in the Base class.
SetDisplay() is a switch to set what of the smaller classes will recieve the call to PaintDisplay().
And PaintDisplay() paints different views of the Base class.
Normal class inheritance says that if I call Red::PaintDisplay() then PaintDisplay() in Red will be called. What I want is to call Base::PaintDisplay() and have one of the smaller classes ( Red, Green, Blue ) catch that call to its own function, depending of what information Base class has - in this case what smaller class gets that function call depends on what Base::SetDisplay() are set to.
So I want the caller of Base::PaintDisplay() to not know about the other small classes but still indirectly call their PaintDisplay() functions depending of what is set through Base::SetDisplay().
Man I feel that this was difficult to explain but I hope some got it and has some ideas of what can be done here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
class Base
{
SetValues();
SetDisplay();
PaintDisplay();
}
class Red : Base
{
PaintDisplay();
}
class Green : Base
{
PaintDisplay();
}
class Blue : Base
{
PaintDisplay();
}
| |