Connecting Tech Pros Worldwide Forums | Help | Site Map

Is this use of enum ok?

pauldepstein@att.net
Guest
 
Posts: n/a
#1: Jan 18 '08
Is there any problem with this code?

class A
{
public:
enum B {C=-1, D = 1, E=2, F = 3, G = 4};


//
//
};

I ask because I've never seen a negative enum value before.

Thanks,

Paul Epstein

Jensen Somers
Guest
 
Posts: n/a
#2: Jan 18 '08

re: Is this use of enum ok?


pauldepstein@att.net wrote:
Quote:
Is there any problem with this code?
>
class A
{
public:
enum B {C=-1, D = 1, E=2, F = 3, G = 4};
>
>
//
//
};
>
I ask because I've never seen a negative enum value before.
>
Thanks,
>
Paul Epstein
In C++ enumerator values can be negative. I think the only problem will
occur if you try to use bitwise operations on them, where you can loose
the negative sign.

- Jensen
Closed Thread