enum

Allows the creation of user defined (enumerated) data types.

 

Enumerated data types consist of a value defined as a symbolic constant, known as an enumerator, starting from zero.

 

Compile & Run:

The enum in the 5th element is Green with a value of: 5

 

 

The defined variable (myValue from above) could have been declared along with the enum definition, as per line 16:

Compile & Run:

The enum in the 5th element is Green with a value of: 5

 

 

Specific values can also be defined:

Compile & Run:

The enum in the 5th element is Green with a value of: 42

Leave a Reply