If i have a class that contains an enum member and that member is not initialized with any data.
I want to check if some value has been placed (sort of validation mechanism I am making for the class to validate all members has been initialized), what can I compare the enum member to? NULL? Or it receives 0 (0 is like the first field so that would not be good for anyone..)
You can’t compare an un-initialized variable with anything, because it’s undefined behavior to read it.
So your safest bet is to keep an
UNSETstate as part of theenum, initialize it to this state, and compare it with that.