-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenums.cpp
More file actions
42 lines (41 loc) · 769 Bytes
/
enums.cpp
File metadata and controls
42 lines (41 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
enum class Color : long
{
RED = 5,
GREEN,
BLUE
};
void FillColor(Color color)
{
// Fill background with some color
if (color == Color::RED)
{
// Paint with red color
std::cout << "RED" << std::endl;
}
else if (color == Color::GREEN)
{
// Paint with green color
std::cout << "GREEN" << std::endl;
}
else if (color == Color::BLUE)
{
// Paint with blue color
std::cout << "BLUE" << std::endl;
}
}
enum class TrafficLight : char
{
RED = 'c',
GREEN,
YELLOW
};
int main()
{
Color c = Color::RED;
FillColor(c);
FillColor(Color::GREEN);
FillColor(static_cast<Color>(2));
int x = static_cast<int>(Color::RED);
return 0;
}