Enumeration, union, and enumeration Union
Enum enumeration and union members share a Variable Buffer
Enum is a basic data type, not a constructor type, because it cannot be broken down into any basic data type.
The value of some variables is limited to a limited range.
The enumerated value is a constant, not a variable.
0, 1, 2, 3, 4...
Enum weekday {sun, mon, tue, wed, thu, fri, sat };
Weekday a, B;
Or
Enum weekday {sun, mon, tue, wed, thu, fri, sat} a, B;
Or
Enum {sun, mon, tue, wed, thu, fri, sat} a, B;
Only enumeration values can be assigned to enumeration variables, and the element values cannot be directly assigned to enumeration variables. If you want to assign a value to an enumerated variable, you must use forced type conversion.
A = (enum weekday) 2; a = (weekday) 2;
That is, a = tue;
Inline week operator ++ (week & rs, int) {// you need to determine whether the value exceeds the range after the overload ++ a ++
Week oldWeek = rs;
Rs = (week) (rs + 1 );
Return oldWeek;
}
All union members share one space and can only store the values of one of the member variables at a time.
Union foo
{
Int I;
Char c;
Double k;
}
Union foo bar; 8 bytes
{Char s [10]; int a ;}10 and 4 occupy 12 bytes
Union members cannot be static or referenced. If they are custom types, they cannot have constructors, deconstruct operators, or copy specified operators.
Assign values to one member, and the values of other Members do not exist.