J
Jon Slaughter
I'm declaring an enum and I would like to limit the scope
I know that
enum day2 {sun, mon, };
is equivalent to
static const int sun = 0;
static const int mon = 1;
but I'd like not to have these global.
I can do day2::sun and use that but I get a warning
about nonstandard extension. It does work though.
I suppose I can wrap it in a static class and use it... maybe something like
static struct day2
{
static const int sun = 0;
static const int mon = 1;
}
Which seems to work but I get errors about no variables in day2. I suppose I
can fix this in some way but I wondering if there is some other better
method. (using the static constant int every time is a little trouble if its
not necessary)
Any ideas?
Thanks,
Jon
I know that
enum day2 {sun, mon, };
is equivalent to
static const int sun = 0;
static const int mon = 1;
but I'd like not to have these global.
I can do day2::sun and use that but I get a warning
about nonstandard extension. It does work though.
I suppose I can wrap it in a static class and use it... maybe something like
static struct day2
{
static const int sun = 0;
static const int mon = 1;
}
Which seems to work but I get errors about no variables in day2. I suppose I
can fix this in some way but I wondering if there is some other better
method. (using the static constant int every time is a little trouble if its
not necessary)
Any ideas?
Thanks,
Jon