title: initializing enum with a constructor
body: <p>I already found this really good explanation <a href="https://stackoverflow.com/questions/12551523/initialising-enum-via-constructors">Initialising enum via constructors</a> but it didn't fit my needs.</p>
  <p>So I declare an enum inside a class and want to initialize it inside the class constructor and then call this enum via a switch statement inside a method but I'm not able to implement it.
  Here is a code:</p>
  <pre><code>    class myClass {
          
          myClass();
          
          enum class State;
  
          void update();
  
          };
      
      
      //  initialise State() with default value, so state1=0, state2=1
      myClass::myClass() : State() {} 
      
      enum class
          myClass::State
          {
              state1,
              state2
          } enumState;
      
      
      
      
      void myClass::update(){
      
      switch (enumState){
      
      case enumState.state1:
           break;
      case enumState.state2:
           break;
  
      }
  }
  </code></pre>
  <p>But obviously it is not the correct way to implement it.</p>
  <p>I get these errors:</p>
  <p>error: ‘enum class myClass::State’ is not a non-static data member of ‘myClass’</p>
  <p>error: request for member ‘state1’ in ‘enumState’, which is of non-class type ‘myClass::State’</p>
  <p>Can someone explain me how to implement such a code and what if I want to initialise State with default parameter ?</p>
  <p>Thank you !</p>