Edit

Share via


Compiler Error C2047

illegal default

The keyword default can appear only in a switch statement.

The following sample generates C2047:

// C2047.cpp
int main() {
   int i = 0;
   default:   // C2047
   switch(i) {
      case 0:
      break;
   }
}

Possible resolution:

// C2047b.cpp
int main() {
   int i = 0;
   switch(i) {
      case 0:
      break;
      default:
      break;
   }
}