How do I use an enum with a switch statement?

Like the title asks, how do I use a switch statement as an enum for the condition?

Enum is represented as integer numbers, so you can just use 0,1,2,3… for case conditions.

enum class EVictoryEnum : uint8

or you can use

enum::value

as condition

Here is more detailed explanation:

Hope it helps.

Regards,
Alex.

I was looking at that article before, when I was structuring out my enum; but it doesn’t explicitly say how to use it within a switch (at least not to my current knowledge).

So here’s my pseudo code and let me know if it seems right (I won’t be able to test it until after work).

Header file:

UENUM(BlueprintType)
enum class EStance : uint8
{
        S_Standing 	UMETA(DisplayName = "Standing"),
        S_Crouching 	UMETA(DisplayName = "Crouching")
};

UCLASS()
class YourClass : public YourSuperClass
{
	GENERATED_UCLASS_BODY()
 
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Enum)
	EStance Stance;
 
	//Rest of Class Code
};

CPP File

switch (Stance)
{
case 0:
// Player is standing
break;

case 1:
// Player is crouching
break;
}

Seems right to me.

or, you can use:

switch (Stance)
{
case EStance::S_Standing: ...
break;
case EStance::S_Crouching: ...
break;
}

Regards,
Alex.