Union declaration
From cppreference.com
| This section is incomplete |
A union is a special class type that stores all of its data members in the same memory location.
Unions cannot have virtual functions and cannot be inherited.
(until C++11) Unions can only contain POD (plain old data) types.
(since C++11) Unions can contains non-trivial types provided that eventual non-trivial constructors are defined by the user.
Syntax
union Template:sparam { Template:sparam } Template:sparam ;
|
(1) | ||||||||
union { Template:sparam } Template:sparam ;
|
(2) | ||||||||
Explanation
| This section is incomplete |
- Named union
- Unnamed union
Example
Output:
as int: 1024 as char: 128
(for little-endian processors)