title: Incomplete type named in nested name specifier
body: <p>I was compiling the following code:</p>
  
  <pre><code>class B;
  
  class A {
      A();
      friend A B::newAObject();
  };
  
  class B {
      friend A::A();
  public:
      A newAObject();
  };
  </code></pre>
  
  <p>This may seem strange, but the idea was to have a class <code>A</code> that could only be produced by an object of type <code>B</code> (who would probably be a singleton).</p>
  
  <p>The problem is that I've created a circular dependency between these objects. <code>A</code> must be defined before <code>B</code>, and <code>B</code> must be defined before <code>A</code>. Apparently forward declaring <code>B</code> is not good enough, <code>B</code> must actually be fully defined before <code>A</code> (and vice versa).</p>
  
  <p>How do I get around this?</p>
  
  <p>Edit: the actual error is: Incomplete type 'B' named in nested name specifier.</p>
  
  <p>Note: there is another post that is similar to this here: <a href="https://stackoverflow.com/questions/4572483/error-incomplete-type-used-in-nested-name-specifier-g">Error: incomplete type used in nested name specifier</a>, but it's heavily templatized and that was confusing me, hence this post.</p>