Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
There is no standard conversion between an enum and an integral type; a cast is required.
Example
Code
// mcppv2_enum_4.cpp
// compile with: /clr
enum class day {sun, mon, tue, wed, thu, fri, sat};
enum {sun, mon, tue, wed, thu, fri, sat} day2; // unnamed std enum
int main() {
day a = day::sun;
day2 = sun;
if ((int)a == day2)
// or...
// if (a == (day)day2)
System::Console::WriteLine("a and day2 are the same");
else
System::Console::WriteLine("a and day2 are not the same");
}
Output
a and day2 are the same