If I have two structs:
struct Base {
int a;
};
struct Derived : Base {
int b;
};
then with an instance Derived d
, I can directly access a
and b
as d.a
and d.b
.
However with this setup, Derived
isn't a standard layout type.
If I wanted to make it standard layout, I could do something like:
struct Derived {
Base base;
int b;
};
but then to access a
I'd have to use d.base.a
instead of d.a
as before.
Can I can declare the Derived
struct in a way that lets me access a
and b
as in the first example, while keeping it a standard layout type?