Kamil Grymuza wrote:
About that enumerated values, I meant that I have an integer value of ID
and I want the name, and when I tested your suggestion with my program.
I have sth. like this:
#define name_of (x) #x
cout<<name_of(event.GetId())<<endl;
it gave me
event.GetId() on screen
so again sorry for not explaining my problem clearly, any ideas now?
Not really. If you don't have duplicate IDs, then you can use Thomas'
suggestion about a 'map<ID,string>'. If you have duplicates, you can't
use that, for obvious reasons.
Whatever other thing you wrote about "names of buttons, text controls
etc.", I have absolutely no idea what you need. You're apparently trying
to solve some problem by "casting" something "from string" or vice versa,
but you didn't say what that problem was. Have you tried simply taking
the address of the variable, converting it to void* and displaying it?
Again, I have no idea if that's what you need because I don't understand
the problem you're trying to solve.
You could, of course, create a 'map<void*,string>' and then add "names"
when you create your objects, and then display those names based on the
address of the object when you feel like it. That's intrusive (requires
you to change code), and not really reliable since you can simply assign
the same "name" to different object addresses and it's not going to stop
you... Maybe that's what you need?
V