'EGuessStatus Status = EGuessStatus::Invalid_Status;' - Is it necessary?

I tried only
‘EGuessStatus Status;’
and it worked.

Is there a reason for putting
‘EGuessStatus::Invalid_Status;’
after ‘EGuessStatus Status’?

1 Like

I think Ben does that so the value of Status is known at all times. I’m not sure what the value of Status might be if is not defined explicitly. I could be wrong though

1 Like

Hello @Sharks_Ley,

enumerations are static. This means they are present all the time without the need to be instantiated.

Writing Enumeration::code instead of code has two significant advantages:

  • If you are working with different namespace or enumerations that contains the same name for it’s member than the other namespace, then you will need to explicit define which code from which namespace do you want.

  • The code is more friendly to read for yourself and at most for programmers who are looking the first time at your code.

Cheers
Kevin

Privacy & Terms