Toon posts:

[C++] Enum->String->Enum

Pagina: 1
Acties:
  • 38 views sinds 30-01-2008

Verwijderd

Topicstarter
I got an enum
string_e {
FIRST_STRING,
VALUE1,
VALUE2,
LAST_STRING,
}

What I want to do is get
1) int tmp = (int) <string_e-variable>
-> Easy & done
2) string_e tmp = ?????? "VALUE1";
-> So FROM the name as a string TO the enumvalue/int.
3) char*tmp = ????? VALUE1; (result: tmp = "VALUE1")
-> So into the string the NAME of the variable...

Anyone in here does know if that's possible with easy to use functions?

Verwijderd

Zoek eens in je C++ STL documentatie iets over Associative Containers zou ik zeggen.

Verwijderd

Kun je dat in het Nederlands vertalen? :{.

ik doe dit via switch/case lijsten (enum->enum-string) of simpelweg via stringvergelijkingen (strcmp) voor enum-string->enum, maar da's C, niet C++.

  • Zoijar
  • Registratie: September 2001
  • Niet online

Zoijar

Because he doesn't row...

std::map<> ?

  • D2k
  • Registratie: Januari 2001
  • Laatst online: 31-08 10:19

D2k

this is a dutch forum
so we expect dutch messages

[ Voor 0% gewijzigd door D2k op 07-08-2002 21:25 . Reden: kannie tiepen ]

Doet iets met Cloud (MS/IBM)


Dit topic is gesloten.