struct Data {}; 2 union U { 3 Data d; // occupies 1 byte 4 std::int32_t n; // occupies 4…
- User
struct Data {}; 2 union U { 3 Data d; // occupies 1 byte 4 std::int32_t n; // occupies 4 bytes 5 char c; // occupies 1 byte 6 ~U() {} // need to know currently active type 7 }; // an instance of U in total occupies 4 bytes.
- Assistant