You are looking for strongly typed enumerations, a feature available in the C++11 standard. It turns enumerations into classes with scope values.
Using your own code example, it is:
enum class Days {Saturday, Sunday, Tuesday,Wednesday, Thursday, Friday};
Days day = Days::Saturday;
if (day == Days::Saturday) {
cout << " Today is Saturday !" << endl;
}
//int day2 = Days::Sunday; // Error! invalid
Using ::
as accessors to enumerations will fail if targeting a C++ standard prior C++11. But some old compilers doesn't supported it, as well some IDEs just override this option, and set a old C++ std.
If you are using GCC, enable C+11 with -std=c++11 or -std=gnu11 .
Be happy!