The enum keyword is used to declare a enum type variable.
enum {value1,value2,...valuen} var[=initializer];
The var here must be an legal variable name.
It is used in the variable declaration.
Declare an enum type variable. An enum type variable must be equal to one of the pre-defined values. The pre-defined values are constant so it is recommended to use uppercase letters.
//lights can only be: RED, AMBER or GREEN.
enum {RED, AMBER, GREEN} lights;
enum {ON, OFF} switch;
normal state PowerOff{
switch=#OFF;
}
@2020-2022 Hao Wu. All rights reserved. Last update: May 1, 2022