In my code I have two almost identical structs, which I have here simplified:
struct foo {
struct bar {
int b;
} a;
};
struct foo2 {
struct qux {
int b;
int c;
} a;
};
(The only difference here is that qux has a member c
while bar does not.)
My question is, Is there a way to let qux inherit from bar, without having to create two foo? This can easily be done with classes, but I want to know if it can be achieved with structs. In my imagination it would look something like this:
struct bar {
int b;
};
struct qux : bar {
int c;
};
struct foo {
bar_or_qux a;
};