Hi,

I have a constant integer variable (i) as a class member of my Class X.
This variable (i) is initialized in the constructor of Class X.

However, why does the compiler prevent the use of the variable (i) in a case statement in the switch-case construct ? After all, is 'i' not a constant ?
The compiler error shown is
Error C2051 : case expression is not constant

Code:
X::X():i(10)
{
}

void X::MyFunction()
{
       switch(_someValue)
       {
               case i :
              {
               }
        };
}
This works if I had defined 'i' as a 'static const int' and initialized it at the point of class declaration.
Could you please explain the above difference ?