c++ - Enum Class "could not convert to unsigned int" -



c++ - Enum Class "could not convert to unsigned int" -

i have enum class this:

typedef unsigned int binary_instructions_t; enum class binaryinstructions : binary_instructions_t { end_instruction = 0x0, reset, set_step_time, set_stop_time, start, add together };

and trying utilize members of enum in switch statement this:

const std::string& function(binary_instructions_t arg, bool& error_detect) { switch(arg) { case (unsigned int)binaryinstructions::end_instruction: homecoming "end"; break; } translate_error = true; homecoming "error"; }

why cast (unsigned int) required when underlying type unsigned int?

that's because "enum class" "strongly-typed", not implicitly convertible other type. http://en.wikipedia.org/wiki/c%2b%2b11#strongly_typed_enumerations

c++ casting enum-class

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -