SFML community forums
Help => General => Topic started by: sill49 on July 29, 2018, 06:26:04 pm
-
Hi there. I'm currently implementing a game of cards in SFML. Obviously, I would like to draw some cards, and I need my object-oriented design to be as flexible as possible for further development.
Therefore, I considered to inherit the Card class from sf::Drawable. The problem is that my Card constructor is constexpr and the sf::Drawable's constructor is not. At least that's what I understand from the error message: constexpr constructor calls non-constexpr function sf::Drawable::Drawable() noexcept".
I could take away the constexpr specifier from the constructor, but there are other pieces of code that rely on that constexpr constructor.
What would be your advice for me? Thanks in advance.
-
Why does the constructor need to be constexpr?
-
It doesn't need to be constexpr, but it's a nice addition. For example, I have an array of 52 cards (the default deck) which can be resolved at compile-time.
-
Just delay the construction of the SFML resources past the actual constructor? You can't really create stuff like OpenGL contexts at compile time anyway.