Thursday, 15 January 2015

c++ - How is enum class similar to enum, or a class? -



c++ - How is enum class similar to enum, or a class? -

this question has reply here:

what's enum class , why should care? 4 answers

is type enum class separate traditional class, or implementation similar? how enum class work? reason inquire because don't understand how can similar both class , enum @ same time. assume enum class cannot have constructor, or internal methods?

it's related ordinary enum in consists of set of names constant values. it's related class in names contained within scope of type's name. so:

enum my_enum { first, second, 3rd }; my_enum value = second; // ok; enumeration names in global scope here enum class my_class_enum { fourth, fifth, 6th }; my_class_enum other_value = fourth; // error my_class_enum another_value = my_class_enum::fourth; // ok

c++ class enums enum-class

No comments:

Post a Comment