基本聯合功能
聯合是一個專門的結構,所有成員都佔據重疊的記憶體。
union U {
int a;
short b;
float c;
};
U u;
//Address of a and b will be equal
(void*)&u.a == (void*)&u.b;
(void*)&u.a == (void*)&u.c;
//Assigning to any union member changes the shared memory of all members
u.c = 4.f;
u.a = 5;
u.c != 4.f;