C++ essentials 之 union
Extraction from The C++ Programming Language 4th. edition, Bjarne Stroustrup
- [8.1] A
structis a sequence of elements (called members) of arbitrary types. Aunionis astructthat holds the value of just one of its elements at any one time. - A
unionis astructin which all members are allocated at the same address so that theunionoccupies only as much space as its largest member. Naturally, aunioncan hold a value for only one member at a time.

浙公网安备 33010602011771号