enum Alpha {A, B, C};
enum class Beta {X, Y, Z};
int main()
{
Alpha alpha = A;
Beta beta = Beta::X;
int alpha_int = alpha;
int beta_int = static_cast(beta); // Cast is necessary in order to compile.
return 0;
}
Reference: https://isocpp.org/wiki/faq/cpp11-language-types#enum-class
Monday, August 7, 2017
C++11: enum class
enum classes do not get implicitly converted to an integer. enum classes are scoped. Here is an example:
Subscribe to:
Post Comments (Atom)
nice post
ReplyDeleteBahaya Merokok