enums are named constant integers. it looks to me like it works; were you expecting to see the name of the enum variable as a string or something? I don't get any errors and it seems to do what it does ok....
you can indeed convert an int to an enum. But, an enum is just an integer, so you haven't accomplished much there beyond silencing an warning from the compiler.
If you want words, you need some other way.
#include <iostream>
struct Date {
unsigned dayOfWeek {};
unsigned dayOfMonth {};
unsigned month {};
unsigned year {};
};
enum DayOfWeek { Sunday = 1, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday};
constexprconstchar* days[Saturday] {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
int main() {
Date userDate;
do {
std::cout << "What day of the week is it (1 - 7)? ";
std::cin >> userDate.dayOfWeek;
} while ((userDate.dayOfWeek < 1 || userDate.dayOfWeek > 7) && (std::cout << "Invalid week day\n"));
do {
std::cout << "What day of the month is it (1 - 31)? ";
std::cin >> userDate.dayOfMonth;
} while ((userDate.dayOfMonth < 1 || userDate.dayOfMonth > 31) && (std::cout << "Invalid month day\n"));
do {
std::cout << "What month is it (1 - 12)? ";
std::cin >> userDate.month;
} while ((userDate.month < 1 || userDate.month > 12) && (std::cout << "Invalid month\n"));
std::cout << "What year is it (####)? ";
std::cin >> userDate.year;
std::cout << '\n' << days[static_cast<DayOfWeek>(userDate.dayOfWeek) - 1] << ", " << userDate.dayOfMonth << "/" << userDate.month << "/" << userDate.year << '\n';
}
What day of the week is it (1 - 7)? 3
What day of the month is it (1 - 31)? 6
What month is it (1 - 12)? 11
What year is it (####)? 2020
Tuesday, 6/11/2020