I want to create a new type of variable which has his own constant values. So I want to do something likes this: (This is a not working example to explain the idea)
class Variabletype {
public:
static const uint8_t Option1 = 0;
static const uint8_t Option2 = 1;
};
typedef const uint8_t Variabletype;
int main() {
Variabletype vt = Variabletype::Option1;
if (vt == Variabletype::Option1)
printf("Option 1\n");
else
printf("Option 2\n");
return 0;
}
I can't typedef the name Variabletype
after declaring it as a class, but I hope it makes clear, what my intention is? The benefit of this idea would be finding directly the possible values of the variable, vt
. I also don't want to spam my global space with constants, and I can not set vt
to impossible values.
So is something like this possible? I already searched a lot but didn't find any solution.