title: c++ "Incomplete type not allowed" error accessing class reference information (Circular dependency with forward declaration)
body: <p>Had some issues in my code recently surrounding what I now know of as a Circular dependency. In short there are two classes, Player and Ball, which both need to use information from the other. Both at some point in the code will be passed a reference of the other (from another class that will include both .h files).</p>
  
  <p>After reading up on it, I removed the #include.h files from each one and went with forward declaration. This solved the issue of being able to declare the classes in eachother, but I'm now left with an "Incomplete type error" when trying to access a passed reference to the object. There seem to be a few similar examples around, though often mixed with more complex code and hard to narrow down to the basics.</p>
  
  <p>I've rewritten the code in it's simplest form (a skeleton essentially).</p>
  
  <p>Ball.h:</p>
  
  <pre><code>class Player;
  
  class Ball {
  public:
      Player&amp; PlayerB;
      float ballPosX = 800;
  private:
  
  };
  </code></pre>
  
  <p>Player.h:</p>
  
  <pre><code>class Ball;
  
  class Player {
  public:
      void doSomething(Ball&amp; ball);
  private:
  };
  </code></pre>
  
  <p>Player.cpp:</p>
  
  <pre><code>#include "Player.h"
  
  void Player::doSomething(Ball&amp; ball) {
      ball.ballPosX += 10;                   // incomplete type error occurs here.
  }
  </code></pre>
  
  <p>Any help understanding why this is the case would be greatly appreciated :)</p>