Пример использования перечисления enum в C++
#include <iostream> using namespace std; enum days_week {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday}; int main() { setlocale(LC_ALL, "Rus"); int x; days_week day1; day1 = Monday; days_week day2= Friday; //days_week day2= days_week::Friday; x = day2 - day1; cout << day1 << endl; // 1 cout << day2 << endl; // 5 cout << x << endl; // 4 system("pause"); }
Вывод программы