July 2015
Intermediate to advanced
558 pages
13h 31m
English
The need to have a value that can hold different types of data at different times during the lifetime of a program is not new. C++ supports the union construct of C, which essentially allows you to have a single type that can, at different times, assume values of different underlying POD types. POD or Plain Old Data types, roughly speaking, are types that do not require any special initialization, destruction, and copying steps and whose semantic equivalents may be created by copying their memory layouts byte for byte.
These restrictions mean that most C++ classes, including a majority of those from the Standard Library, can never be part of a union. Starting with C++11, these restrictions on a union have been ...
Read now
Unlock full access