1

In C# when requiring to get the textual value of an enum by the index value we can do:

String i = ((Enum_Type)index)).ToString();

However, it seems that such value cannot be accessed in c++ as conveniently as this. I've tried (Enum_Type)index but it seems that it still return a numeric value. I know that the best alternative to enums would be always data model class, however, I'm curious how this can be done in C++, as I'm from a C# background C++ is a lower lever language and little abstract to me.

** Update: Why requiring enum at all?

I have a text file with a series of numeric values that I only wanna be known to the developer, so by reading them and casting them to integers I wanna get the actual value out of the enum.

Dev Arc
  • 37
  • 6

0 Answers0