Suppose we have an enum like the following:
enum Days {Saturday, Sunday, Tuesday, Wednesday, Thursday, Friday};
I want to create an instance of this enum and initialize it with a proper value, so I do:
Days day = Days.Saturday;
Now I want to check my variable or instance with an existing enum value, so I do:
if (day == Days.Saturday)
{
std::cout << "Ok its Saturday";
}
Which gives me a compilation error:
error: expected primary-expression before ‘.’ token
So to be clear, what is the difference between saying:
if (day == Days.Saturday) // Causes compilation error
and
if (day == Saturday)
?
What exactly do these two terms mean, in that one is OK and the other generates a compilation error?