title: C++: Including header files in each other
body: <p>So I have seen this question asked, but the examples people provided were extremely simple (their classes had no constructors or methods) and I don't know how to extend the solutions to a more complex case. </p>
  
  <p>I have tried using forward declarations and pointers, just forward declarations, just pointers, and even forward declarations and typename definitions, all of which were suggested solutions from the other simpler posts and none of which have worked (unknown identifier or incomplete type errors). So how would I get the two files below to compile correctly and be used as I intended?</p>
  
  <p>Unit.hpp:</p>
  
  <pre><code>#ifndef PROJECT_UNIT_HPP
  #define PROJECT_UNIT_HPP
  
  #include "GridNode.hpp"
  
  class Unit
  {
  private:
      /* Fields */
      int xPos, yPos, ownerID;
      std::vector&lt;GridNode&gt; influenceMap;
  
  public:
      /* Constructors */
      Unit(int x, int y, int id) : xPos(x), yPos(y), ownerID(id)
      {
          influenceMap.push_back( GridNode() );
      }
  
      /* Methods */
      std::vector&lt;GridNode&gt; getMap() {return influenceMap;}
  };
  
  #endif
  </code></pre>
  
  <p>GridNode.hpp:</p>
  
  <pre><code>#ifndef PROJECT_GRIDNODE_HPP
  #define PROJECT_GRIDNODE_HPP
  
  #include "Unit.hpp"
  
  class GridNode
  {
  private:
      /* Members */
      int id;
      std::vector&lt;Unit&gt; nodeUnits;
  
  public:
      /* Static vars */
      static int nodeLength;
  
      /* Constructors */
      GridNode()
      {
          std::cout &lt;&lt; "Reached here!\n";
      }
  };
  
  #endif
  </code></pre>