Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3491528
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:38:51+00:00 2026-05-18T11:38:51+00:00

This is a bit tricky to explain but I will try my best to

  • 0

This is a bit tricky to explain but I will try my best to explain it.

I’m making a Gui API for games and it has Themes.

First I’ll explain how Widgets work.

A Button for example, inherits from Widget.
Themes work similarly.

ButtonTheme inherits from WidgetTheme.

Inside each widget class, there is an instance of its corrosponding Theme.

Widget class has:

    private:
   static WidgetTheme widgetTheme;
    public:
   static WidgetTheme& getWidgetTheme();

button class has:

  private:
    static ButtonTheme buttonTheme;
    public:
   static ButtonTheme& getButtonTheme();

the Widget constructor, builds itself from its theme ex:

Widget()
{
   setFont(getWidgetTheme().getFont());
}

the Button, inheriting from WidgetTheme, has to do the same ones because the internal widget will not know to construct from ButtonTheme, so my button ends up having to do:

Button()
{
   setFont(getButtonTheme().getFont());
   setButtonPadding(getButtonTheme().getButtonPadding());
}

This is where my problem is. It really feels wrong that I have to reprovide all the WidgetTheme ones and redirect them to ButtonTheme’s parameters for Widget. If I do not do this, a SuperButton would inherit the styles of Button which would also inherit the styles of Widget, but what I want is for SuperButton to use its version of ButtonTheme and WidgetTheme because SuperButtonTheme would inherit from ButtonTheme and WidgetTheme.

Is there a way I could redesign this so that the constructor only has to set parts of the theme that it brings, and not have to set those of its parents?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:38:52+00:00Added an answer on May 18, 2026 at 11:38 am

    A virtual getTheme() (as drewish suggests) but using covariant return types ought to solve your problem without requiring casts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a bit lost as to how to explain this, so I will
Bit tricky to communicate but hope this makes sense. I have 8 div containers
Ok, this is bit of an obscure question, but hopefully someone can help me
This is a bit of a long shot, but if anyone can figure it
This might be a bit difficult to explain in writing, so please bear with
I'm finding this a bit tricky! Maybe someone can help me on this one
I have this bit of javascript written with jQuery 1.2.5. It's contained inside the
I have this bit of script to widen a text box on mouseover and
I have this bit of code I found on the web at the end
I'm trying to understand this bit of code: in display.php: <html> ... <body> <table>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.