|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
pauldepstein@att.net wrote:
> 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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 2008-01-18 01:51:11 -0500, Jensen Somers <jensen.somers@gmail.com> said:
> > 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. > Doing bitwise operations on negative values, whether or not they're enumerations, is dicey. In order to know what the result should be, you have to know how the values are represented. -- Pete Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The Standard C++ Library Extensions: a Tutorial and Reference (www.petebecker.com/tr1book) |
|
![]() |
| Outils de la discussion | |
|
|