enum error 
Author Message
 enum error

In VC++ v6.0 I have declared:

class CFred
{
public:
 // Data
 static enum Authentication {NotPerformed, Successful };
 static enum Authorization {NotPerformed, Successful,
InvalidElectronicSerialNo, UnassignedDirectoryNo};
...

and the compiler reports the following error:

Compiling...
xx.cpp
...: error C2371: 'NotPerformed' : redefinition; different basic types
        xxx.h(767) : see declaration of 'NotPerformed'
xxx.h(768) : error C2371: 'Successful' : redefinition; different basic types
        xxx.h(767) : see declaration of 'Successful'
==============================
Since the enum cases 'NotPerformed' and 'Successful' are in different enums
why does the compiler flag an error?

Regards.



Fri, 18 Feb 2005 07:44:55 GMT  
 enum error

Quote:
> In VC++ v6.0 I have declared:

> class CFred
> {
> public:
>  // Data
>  static enum Authentication {NotPerformed, Successful };
>  static enum Authorization {NotPerformed, Successful,
> InvalidElectronicSerialNo, UnassignedDirectoryNo};
> ...

> and the compiler reports the following error:

> Compiling...
> xx.cpp
> ...: error C2371: 'NotPerformed' : redefinition; different basic types
>         xxx.h(767) : see declaration of 'NotPerformed'
> xxx.h(768) : error C2371: 'Successful' : redefinition; different basic
types
>         xxx.h(767) : see declaration of 'Successful'
> ==============================
> Since the enum cases 'NotPerformed' and 'Successful' are in different
enums
> why does the compiler flag an error?

Enums are no namespaces. So all enum values in all enums (in the same
namespace) must be different to each other and different from all other
names in the same namespace. Otherwise you would have to write
Authentication::NotPerformed etc. and most of us wouldn't like that.

Regards
    Heinz



Sat, 19 Feb 2005 19:58:03 GMT  
 enum error
Thanks. So enums are fake name protection. What is the better approach:
classes? namespaces?

Regards.

Quote:


> > In VC++ v6.0 I have declared:

> > class CFred
> > {
> > public:
> >  // Data
> >  static enum Authentication {NotPerformed, Successful };
> >  static enum Authorization {NotPerformed, Successful,
> > InvalidElectronicSerialNo, UnassignedDirectoryNo};
> > ...

> > and the compiler reports the following error:

> > Compiling...
> > xx.cpp
> > ...: error C2371: 'NotPerformed' : redefinition; different basic types
> >         xxx.h(767) : see declaration of 'NotPerformed'
> > xxx.h(768) : error C2371: 'Successful' : redefinition; different basic
> types
> >         xxx.h(767) : see declaration of 'Successful'
> > ==============================
> > Since the enum cases 'NotPerformed' and 'Successful' are in different
> enums
> > why does the compiler flag an error?

> Enums are no namespaces. So all enum values in all enums (in the same
> namespace) must be different to each other and different from all other
> names in the same namespace. Otherwise you would have to write
> Authentication::NotPerformed etc. and most of us wouldn't like that.

> Regards
>     Heinz



Sun, 20 Feb 2005 12:38:38 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. enum error

2. typedef enum as subset of another enum

3. enum - enum ?

4. enum - enum ?

5. internal compiler error when boxing an enum defined in a precompiled header

6. BUG: DEBUG member in enum in class syntax error C2059

7. enum base-type string error

8. Defining enum in interface yields error MIDL2001

9. enum compiler error?

10. **UNKNOWN TYPE** Server Error when using enum cross process from web app

11. error, error, error !!!

12. Enum on Hashtable help !

 

 
Powered by phpBB® Forum Software