Enumerations
An enumeration is a user-defined data type that holds a list of integer constants, where each item has a human-friendly name assigned by you, which makes the code easier to read. As an example, we could use an integer variable to represent the different states that a character can be in – 0
means it's idle, 1
means it's walking, and so on. The problem with this approach is that when you start writing code such as if(State == 0)
, it will become hard to remember what 0
means, especially if you have a lot of states, without using some documentation or comments to help you remember. To fix this problem, you should use enumerations, where you can write code such as if(State == EState::Idle)
, which is much more explicit and easier to understand.
In C++, you have two types of enums, the older raw enums and the new enum classes, introduced in C++11. If you want to use C++ enumerations in the editor, your first instinct might be to do it in the typical way,...