enum class Color { red, blue, green };
Color x = Color{5};
The second statement gives me error (main.cpp:20:23: error: cannot convert ‘int’ to ‘Color’ in initialization). I was going through the c++ book it says it's OK to initialize the way in the second statement. I'm confused whether can we use int in initializing the enum type (Color here).
Aucun commentaire:
Enregistrer un commentaire