V
Vane
According to said:enum flag { x = 1, y = 2, z = 4, e = 8 }; //range 0:15
...
flag f4 = flag(99); // undefined : 99 is not within the range of flag
But the following codes has result 99.
//--------------------------------------------------
#include "iostream"
int main(int argc, char* argv[])
{
enum flag{ x = 1, y = 2, z = 4, e = 8 };
flag f1 = flag( 99 );
std::cout<<f1<<std::endl;
return 0;
}
//----------------------------------------------------
Whether the compiler treats enum type as integral type? Then what's the
meaning of the range of enum?