Unable to access Enum constants defined in header file from .cc file.

Hello all,
I am getting below error while trying to compile C++ code

cookieSetter.cc:126: error: nav cannot appear in a constant-expression
cookieSetter.cc:126: error: `.' cannot appear in a constant-expression


Basically there is a enum list defined inside a header file"navBuilder.h" and a function inside cookieSetter.cc file is trying to access the enum constant with a dot "." operator. below is the code snippet from header and .cc file.

1) navBuilder.h
1
2
3
4
5
6
7
8
9
10
class navBuilder
{
public:
    enum {
       constant1 = 1,
       constant2 = 2
     };
   	navBuilder();
	~navBuilder();
};


2) cookieSetter.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "navBuilder.h" 

navBuilder nav;

int determineScreen()
{
   switch( screenNumber )
	{
	case nav.constant1:
		 do something ....
            	 break;
        case nav.constant2:
		 do something ....
            	 break;
        };
}

Many thanks for your help..
I think you meant to use :: instead of . ?
no i am using "." dot operator , this code was working fine on Solaris, Its giving problem when i am migrating to linux64bit.

I tried using :: but it is as well not working i did something like below

case nav::constant1:
do something.
break;
It should be
1
2
3
case navBuilder::constant1:
	do something ....
	break;

codewalker , Peter,

Many thanks, the suggested changes worked.. it was the last piece of code that was not compiling..
Topic archived. No new replies allowed.