c++ - Assigning values to enum -
while doing review of older code, notice following 2 strange constructions using enum (two different files/classes/namespaces, putting them here): enum firstenum { a_choice ,another_choice=1 ,yet_some_other_choice }; enum secondenum { first_choice ,second_choice ,third_choice ,default_choice=second_choice }; i think both constructions wrong. the first 1 assigns value 1 of choices, not others, meaning things might go wrong if new choices added. in second case, end 2 enumeration elements having same underlying value. is there reason why c++ standard allows both constructions? (using visual studio 2010) the first 1 assigns value 1 of choices, not others, meaning things might go wrong if new choices added. i don't know mean "go wrong". it's well-defined if don't specify value enumerator, value 1 more previous (or zero, if it's first). in second case, end 2 enumeration elements having same unde...