#include <iostream.h>
int main()
{
enum Days { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Â_Saturday };
Days DayOff;
int x;
cout << "What day would you like off (0-6)? ";
cin >> x;
DayOff = Days(x);
if (DayOff == Sunday || DayOff == Saturday)
cout << "\nYou're already off on weekends!\n";
else?
cout << "\nOkay, I'll put in the vacation day.\n";
return 0;
}
This code appears in an example problem in the tutorial entitled "Teach Yourself c++ in 21 days." I've already started a few other tutorials (they weren't very good), so most of this is review for me. But enums were never covered.
In line 6, what the heck does that mean. It looks like he's declaring variables, but there is no type. Do you think this is just an error.
In line 11, what does days(x) mean? I'm going to guess this is a reference to the values that correspond to each day of the week in the enum. Additionally, it happens to be an x, because cin calls for x.
Lastly, in line 13, where it says "if (DayOff == Sunday || DayOff == Saturday)", could I have used the values of Sunday and Saturday instead. For example, could I have written if (DayOff == 0 || DayOff == 6)?
Thank you in advance.