Skip to content

Trying to understand poly #1256

Answered by skypjack
rudiHammad asked this question in Q&A
May 21, 2025 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Until you don't want to iterate them all at once throught their base class, that's perfectly fine then.
In my own projects I favor composition in this case actually. Something like:

struct hitbox {
    rect_type area;
    // other data
};

Where rect_type is your base class (more or less, you have more data, but you get what I mean).
It's a matter of tastes. A non-virtual base used to share the design of a piece of information is also ok.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@skypjack
Comment options

Answer selected by rudiHammad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
discussion it sounds interesting, let's discuss it
2 participants