[=Dijon;123410]
In the “Introduction to C++” tutorial by Lauren Ridge, she uses the following enum:
enum class ETutorialCodePlayState : short
{
EPlaying,
EGameOver,
EUnknown
};
From my admittedly novice perspective, it looks like this feature has been in UE4 for a while. I also note that she used “short” as the data type, which I believe is an int16, rather than a uint8. I asked about this departure from the published Coding Standard in the tutorial’s forum but no one was able to answer. Her format (and now yours) is definitely less verbose, so can you clarify for me what is new? For a C++ noob, this is still a little confusing. Thanks.
Dean
[/]
The enum class syntax was introduced in C++11. It gives you the benefit of scoped enums (like you get in C# or Java) without having to manually scope them within a namespace. It also allows you to specify the storage type for the enum which is super rad because if you only have 5 values then you don’t need a full 32 bits.
So in short it simply allows you to type less and get more.
As for using a short in the example, that will be truncated to a byte by the serialize I imagine.
/