#include <iostream>
#include <iostream>

enum class Color {
    Red,
    Green,
    Blue
};

int main() {
    Color c = Color::Red;
    std::cout << "The color is: ";
    switch (c) {
        case Color::Red:
            std::cout << "Red" << std::endl;
            break;
        case Color::Green:
            std::cout << "Green" << std::endl;
            break;
        case Color::Blue:
            std::cout << "Blue" << std::endl;
            break;
    }
    return 0;
}


/*In this example, the program defines an enum class named Color with three enumerators
Red, Green, and Blue. The enum class keyword is used to define an enumeration in 
which the enumerators are in the scope of the enum and are not visible to the
enclosing scope unless explicitly qualified.

The program then declares a variable c of type Color and assigns it the value 
Color::Red. The program then uses a switch statement to print the value of the
color.

The output of the program will be "The color is: Red".

It's worth noting that C++11 and later versions introduce the enum class keyword,
this allows to define enumerations that are strongly typed and have a scope, which
prevent enumerators from conflicting with other enumerations or variables in the 
global namespace.*/

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: