📺视频链接
- just integer
- a set of values
- a way to a name to a value
int A = 0;
int B = 1;
int C = 2; // are not group
int main()
{
int value = B;
if(value == B){
// Do something here
}
}
// by defult the first one will be 0,
// increment one by one
enum Example : unsigned char{
A, B, C
};
int main()
{
Example value = B;
if(value == B){
// Do something here
}
}
- only have one member
- want multiple ways to address that same data
struct Union{
union{
float a;
int b;
};
};
Union u;
u.a = 2.0f;
std::cout << u.a << ", " u.b << std::endl;