-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnums.cpp
More file actions
53 lines (43 loc) · 1.14 KB
/
Enums.cpp
File metadata and controls
53 lines (43 loc) · 1.14 KB
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
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
enum Day
{
sunday = 0,
monday = 1,
tuesday = 2,
wednesday = 3,
thursday = 4,
friday = 5,
saturday = 6
};
int main()
{
//enums = a user defined data type that consists of paired name integer constants
// GREAT if you have a set of potential solutions
//std::string today = "sunday"; //normally cannot use strings in switches so we use enums
Day today = friday; // could also have the cases below be the int value but its less readble here
switch(today)
{
case sunday:
std::cout << "It is Sunday!\n";
break;
case monday:
std::cout << "It is Monday!\n";
break;
case tuesday:
std::cout << "It is Tuesday!\n";
break;
case wednesday:
std::cout << "It is Wednesday!\n";
break;
case thursday:
std::cout << "It is Thursday!\n";
break;
case friday:
std::cout << "It is Friday!\n";
break;
case saturday:
std::cout << "It is Saturday!\n";
break;
}
return 0;
}