Enum User Defined Type

In this example, we create a simple User defined data type using enum. For simplicity we create a DayOfWeek datatype

#include <cstdio>

enum class DayOfWeek {
    Monday,
    Tuesday,
    Wednesday,
    Thursday,
    Friday,
    Saturday,
    Sunday
};

int main() {
    // Initializing Enums
    DayOfWeek weekday_one = DayOfWeek::Tuesday;
    DayOfWeek weekend_one = DayOfWeek::Saturday;

    printf("Day of Week %d \n", weekday_one);
    printf("Day of Week %d \n", weekend_one);
}

We expect the program to initialize two variables with DayOfWeek enum type and print out their respective indeces

$ g++ enum_example.cpp -std=c++17 -o enum_example 
$ ./enum_example
Day of Week 1 
Day of Week 5