C++ essentials 之 union

Extraction from The C++ Programming Language 4th. edition, Bjarne Stroustrup

  1. [8.1] A struct is a sequence of elements (called members) of arbitrary types. A union is a struct that holds the value of just one of its elements at any one time.
  2. A union is a struct in which all members are allocated at the same address so that the union occupies only as much space as its largest member. Naturally, a union can hold a value for only one member at a time.
原文地址:https://www.cnblogs.com/Patt/p/5857605.html