title: C++: Confusion with forward declaring classes and using `#include` statements
body: <p>Here's my <code>main.cpp</code>:</p>
  
  <pre><code>...
  #include "primitive.h"
  #include "intersection.h"
  ...
  </code></pre>
  
  <p>And my <code>Primitive.h</code>:</p>
  
  <pre><code>#ifndef PRIMITIVE_H_
  #define PRIMITIVE_H_
  
  #include "intersection.h"
  
  // Forward declaration
  class Intersection;
  
  class Primitive {
      public:
          bool intersect(Ray&amp; ray, float* tHit, Intersection* in) {
              return false;
          }
  };
  
  class GeometricPrimitive : public Primitive {
      public:
          bool intersect(Ray&amp; ray, float* tHit, Intersection* in) {
              DifferentialGeometry differentialGeometry;
              if (!shape-&gt;intersect(ray, tHit, &amp;differentialGeometry)) {
                  return false;
              }
              in-&gt;primitive = this;
              in-&gt;differentialGeometry = differentialGeometry;
              return true;
          }
  
          bool intersectP(Ray&amp; ray) {
              return shape-&gt;intersectP(ray);
          }
  
          BRDFCoefficients getBRDF(DifferentialGeometry&amp; differentialGeometry, BRDFCoefficients* brdf) {
              return material-&gt;getBRDF(differentialGeometry, brdf);
          }
  };
  
  #endif
  </code></pre>
  
  <p>And my <code>Intersection.h</code>:</p>
  
  <pre><code>#ifndef INTERSECTION_H_
  #define INTERSECTION_H_
  
  // Forward declaration
  class Primitive;
  
  class Intersection {
      public:
          Primitive *primitive;
  
          Intersection() {
  
          }
  
          Intersection(DifferentialGeometry differntialGeometry, Primitive *primitive) {
              this-&gt;differentialGeometry = differentialGeometry;
              this-&gt;primitive = primitive;
          }
  };
  #endif
  </code></pre>
  
  <p>When I leave out the line <code>#include "intersection.h"</code> in <code>Primitive.h</code>, I get the error <code>error: member access into incomplete type 'Intersection'</code> in lines</p>
  
  <p><code>in-&gt;primitive = this;</code>
  and 
  <code>in-&gt;differentialGeometry = differentialGeometry;</code> of <code>Primitive.h</code>. Why is this? </p>
  
  <p>Am I forward declaring and using my <code>include</code> statements (for <code>Primitive</code> and <code>Intersection</code>) in the usual, correct way?</p>