Thread View: comp.std.c++
1 messages
1 total messages
Started by Claus A. Faerber
Mon, 18 Mar 1996 17:47
Re: String value of enum
Author: Claus A. Faerber
Date: Mon, 18 Mar 1996 17:47
Date: Mon, 18 Mar 1996 17:47
30 lines
2072 bytes
2072 bytes
W. Dicks <wd@isis.co.za> (13 Mar 96):
> The system that I'm working often needs to know the string
> value of an enum. e.g. enum week{MON=1, ..., SUN} it; it =
> TUE;
> Then when this enum is passed as a parameter the function
> should return the string based on the enum. For instance,
> weekImage(it) will return "TUE". Is it not possible that such
> a functionality can be built into enums?
It is possible, but I would not appreciate it.
If this were possible, it would make the program's output
depend on internal variable/type names, which is generally
not a good idea. Especially when you want to translate your
program into other languages, it is easier to change this
enum-to-string function (or even a seperate string table)
instead of every line of code where this enum is used.
Claus
-------------------------------------------------------------------------
Claus Andre Faerber - claus@faerber.muc.de - http://www.muc.de/~cfaerber/
-------------------------------------------------------------------------
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads