Re: smarter enums
From: Aguilar, James (jfa1_at_cec.NOBOTSwustl.edu)
Date: 07/12/04
- Next message: Aguilar, James: "Re: Pointers to functions: How is the proper function selected?"
- Previous message: Victor Bazarov: "Re: smarter enums"
- In reply to: Mark A. Gibbs: "Re: smarter enums"
- Next in thread: Robbie Hatley: "Re: smarter enums"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 12 Jul 2004 00:11:59 -0400
"Mark A. Gibbs" <x_gibbsmark@rogesr.com_x> wrote in message
news:RWnIc.879359$Ar.376465@twister01.bloor.is.net.cable.rogers.com...
>
> [snip]
I don't have any advice to give you about how to do this, since I am just
learning the language myself. However . . .
I don't think that what you're trying to do is worth your time. My
understanding is that you are trying to design an enum that has some minor
added features over a standard enum. Basically, it's an enum that also
gives you the ability to define class functionality, such as methods and
operators.
But, as I understand it, the whole point of enums is that they aren't
classes, but just ints masked by constant names. They are supposed to be
quick and simple, with no bells and whistles. With C++, they also have
types, but those are simply to guarantee that the user knows what's going
on. AFAIK, you can still throw them around like the ints they represent,
such as:
enum Result { SUCCESS, FAILURE };
int main()
{
...
if (!error()) return SUCCESS;
else return FAILURE;
}
So my advice, which you might take, even though I'm as new to C++ as the
next guy, is to define classes if you need methods, and let enums be enums.
- Next message: Aguilar, James: "Re: Pointers to functions: How is the proper function selected?"
- Previous message: Victor Bazarov: "Re: smarter enums"
- In reply to: Mark A. Gibbs: "Re: smarter enums"
- Next in thread: Robbie Hatley: "Re: smarter enums"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|