title: Why static const members cannot appear in a constant expression like 'switch'
body: <p>I have the following declaration of some static const members </p>
  
  <p>.h</p>
  
  <pre><code>class MyClass : public MyBase
  {
  public:
      static const unsigned char sInvalid;
      static const unsigned char sOutside;
      static const unsigned char sInside;
      //(41 more ...)
  }
  </code></pre>
  
  <p>.cpp</p>
  
  <pre><code>const unsigned char MyClass::sInvalid = 0;
  const unsigned char MyClass::sOutside = 1;
  const unsigned char MyClass::sInside = 2;
  //and so on
  </code></pre>
  
  <p>At some point I want to use those value in a switch like :</p>
  
  <pre><code>unsigned char value;
  ...
  switch(value) {
      case MyClass::sInvalid : /*Do some ;*/ break;
      case MyClass::sOutside : /*Do some ;*/ break;
      ...
  }
  </code></pre>
  
  <p>But I get the following compiler error: <em>error: 'MyClass::sInvalid' cannot appear in a constant-expression</em>.</p>
  
  <p>I have read other switch-cannot-appear-constant-stuff and didn't find an answer for me since I don't get why those <code>static const unsigned char</code> are not constant-expression. </p>
  
  <p>I am using gcc 4.5.</p>