NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Compiler Error C2051

case expression not constant

Case expressions must be integer constants. The following sample generates C2051:

class X {
   public:
   operator const int() { 
      return 1; 
   }
};

void fail() {
}

void main() {
   static X x;
   int i = 0;

   switch (i) {
      case x:      // C2051, use constant expression to resolve error
      // try ...
      // case 1:
         break;
      default:
         fail();
         break;
   }
}