Enums are deprecated, and you should not use them.
Enum Classes (aka Scoped Enums), however, are not deprecated, and are a way to create an enumeration of a limited number of possible values for new type.
1 2 3 4 5 6
enumstruct EnemyType
{
Ground,
Flying,
Ghost
};
The above enum class creates a new data type, known as EnemyType, which may only take on one of the values listed.
why are enums deprecated? they still have plenty of uses and make my data more organized. i dont need them, but it would make it a lot harder and a lot more code to use other things
the point of an enum isnt to create a new type. its to help make data a bit easier to read, like with sfml video modes, instead of just doing ints. if you want to make a type use a data structure
You shouldn't use an enumeration for that, those should be constant variables. I'm really against the idea of assigning specific values to enumeration elements.
But it still is implicitly convertible to an int and not its own type, which is why I don't like it.
In my C code I would be doing something like this:
1 2 3 4 5 6 7 8
enum Colors
{
Red,
White,
Blue
};
void pixel_draw(int x, int y, enum Colors c);
If another programmer willingly disregards the signature of that function, then the problems are much greater than anything a "proper" enum type could fix.
i feel like ive had this argument with fred before... its not the point of enums to supply that. its job is to make data a bit more clear, like typedef