title: C++ Circular dependency due to enum class nested
body: <p>I have a circular dependency created by a nested enum.</p>
  
  <pre><code>class A
  {
      enum class A_enum {};
  
      void method_which_uses_class_B() {}
  }
  
  class B
  {
      void method_which_uses_A_enum() {}
  }
  </code></pre>
  
  <p>That gives you an idea of the overall structure.</p>
  
  <p>Specifically, I have the enum class defined in this way:</p>
  
  <pre><code>... file containing class A
  
  class A
  {
      enum class A_enum
      {
          ITEM_A, ITEM_B
      };
  
      // then the rest of A goes here
  }
  
  // in my main code file
  
  #include "class B file"
  #include "class A file"
  
  ... code
  </code></pre>
  
  <p>The solution therefore would be to move the enum class out of <code>class A</code> and put code/files/include's in the correct order to prevent the problem.</p>
  
  <p>But it's rather nice to have the enum class nested inside <code>class A</code> for my purposes. Is there a way of pre-defining that there will be a <code>class A</code> and what the enum inside that class will be? I tried the following, but it didn't work because I was defining the class twice:</p>
  
  <pre><code>class A;
  
  enum class A::A_enum
  {
      contenta, contentb
  };
  </code></pre>
  
  <p>or</p>
  
  <pre><code>class A
  {
      enum class A_enum {...};
  }
  </code></pre>
  
  <p>then</p>
  
  <pre><code>class A
  {
      // the rest of it
      // obviously doesn't work because already defined class A
  }
  </code></pre>