0
How to use enum in c++
I'm a bit conversant with enum in c but not in c++ are they the same or is there any addition or replacement
1 Odpowiedź
+ 1
There are some small chages, but C enums also works in C++
1)In C++ enum can be declared as
enum class Color{Red, Green, Blue}
and only one way is allowed to access e.g.:
Color color = Color::Red;
...
if(color == Color.Green){}
also you can using forward declaration
enum class Color;
2)You can change the size:
enum class Color : char {...}
so sizeof(Color) == sizeof(char)