In a header that I can’t edit, I have the following defines:
#define ENUM_SOMETHING_A "A"
#define ENUM_SOMETHING_B "B"
#define ENUM_SOMETHING_C "C"
I would like to wrap these in an enum, something similar to:
enum Something {
A = ENUM_SOMETHING_A,
B = ENUM_SOMETHING_B,
C = ENUM_SOMETHING_C
};
Where Something::A is the decimal ASCII value of ENUM_SOMETHING_A, and so on.
I’ve tried several approaches to this, but I can’t figure out how to do this. Is it possible, and if so, how can I accomplish it? Again, the #defines cannot be changed.
I tried casting, and I tried ENUM_SOMETHING_A[0], but neither worked. Also – this is not C++0x.
Enum values cannot be strings, so using an enum isn’t really appropriate here, unless you want to add an additional mechanism to map the enum values to their string counterparts. However, you could do something like this: