Export (0) Print
Expand All
Expand Minimize

Compiler Error C2047

Error Message

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;
   }
}

Community Additions

ADD
Show:
© 2014 Microsoft