I have the base class Panel, which stores some information about the window, then I have subclasses for all the controls: Button, Label, etc. In the base class, I have a method virtual void ApplySchemeSettings(Scheme* scheme) { }that is called inside the constructor Panel(Panel* parent). But instead of a subclass, it is called ApplySchemeSettingsfrom the base class ( Panel).
class Panel
{
[...]
public:
virtual void ApplySchemeSettings(Scheme* scheme) { };
Panel(Panel* parent)
{
[...]
this->ApplySchemeSettings(scheme());
};
}
class Frame : public Panel
{
[...]
public:
void ApplySchemeSettings(Scheme* scheme)
{
this->border = scheme->GetBorder("FrameBorder");
}
}
I cannot declare ApplySchemeSettingsabstractly because subclasses are made by the user.
source
share