|
|
От: |
Eeel
|
|
| Дата: | 20.06.16 14:09 | ||
| Оценка: | |||
| C++ 14 9.5.1 | |
| In a union, at most one of the non-static data members can be active at any time, that is, the value of at most one of the non-static data members can be stored in a union at any time. [ Note: One special guarantee is made in order to simplify the use of unions: If a standard-layout union contains several standard-layout structs that share a common initial sequence (9.2), and if an object of this standard-layout union type contains one of the standard-layout structs, it is permitted to inspect the common initial sequence of any of standard-layout struct members; see 9.2. — end note ]... | |
struct A
{
int a;
int b;
double c;
};
struct B
{
int a;
int b;
float c;
};
union Foo
{
A a;
B b;
};
Foo foo;