title: Mutually Dependent class declarations
body: <p>I am trying to figure out what this compile error means, and I hope I explain this well.</p>
  <pre><code>In file included from sys/charon.cpp:4:0:
  </code></pre>
  <p>Following this takes me to that ^ file above, and underlines in yellow this:</p>
  <pre><code>#include &quot;../headers/charon.h&quot;
  </code></pre>
  <p>As well the type identifier &quot;charon_&quot;, which is a class defined within the header file charon.h, is also underlined in yellow possibly a different error.</p>
  <pre><code>sys/../headers/charon.h:17:9: error: redefinition of ‘class charon::charon_’
  sys/../headers/chio.h:86:9: error: previous definition of ‘class charon::charon_’
  sys/charon.cpp:12:20: error: definition of implicitly-declared ‘charon::charon_::charon_()’
  </code></pre>
  <p>However I hope they are all related to the first error, I think it is related to something I am trying to do.</p>
  <pre><code>//File 1.h
  /**********/
  class I
  {
  private:
  B* my_private_b;
  
  public:
  I(B&amp; handle);
  }
  </code></pre>
  <p>Unfortunately I need 'B' declared before 'file 1' begins defining 'I'.. yet at the same time, I need I to be defined for B. So I don't know how to define both before the other.. I am guessing I need a more advanced solution but I don't know.</p>
  <pre><code>//File 2.h
  /***********/
  class B
  {
  private:
  I i;
  O o;
  
  public:
  B();
  }
  </code></pre>
  <p>So if I can find an answer to that, then maybe I could just check this next part for myself. If you think it would be good to check to see if I am going in the right direction I will paste all the code in question below.</p>
  <h1>.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.</h1>
  <p>Not Long Enough, Didn't Read?
  Well here are all the lines, except for the comments, of code from all four files. In order of perceived importance.</p>
  <pre><code>//////////////////////////////////////
  /////
  /////////////
  /////
  /////
  /////
  //File: chio.h
  
  #ifndef CHIO_H
  #define CHIO_H
  #include &lt;deque&gt;
  #include &lt;queue&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  namespace charon
  {
    class charon_
    {
      
    };
  }
  namespace chio
  { 
    class chout_
    {
    private:
      
    public:
      chout_();
      ~chout_();
    };
    
    class chin_
    {
    private:
      charon::charon_* engine;
  
    public:
      chin_(charon::charon_&amp; handle);
      chin_();
      ~chin_();
    };
  }
  
  #endif  /* CHIO_H */
  
  //////////////////////////////////////
  /////
  /////////////
  /////
  /////
  /////
  //File: charon.h/* 
  //
   * File:   charon.h
   * Author: josh
   *
   * Created on 11 April 2012, 22:26
   */
  
  #ifndef CHARON_H
  #define CHARON_H
  //#include &quot;boost/thread.hpp&quot;
  #include &quot;chio.h&quot;
  
  using namespace std;
  using namespace chio;
  namespace charon
  {
    class charon_ {
    private:
      chout_ engine_output;
      chin_ engine_input;
      //boost::thread input_thread;
      //boost::thread output_thread;
      void start_threads();
      void stop_threads();
  
    public:
      charon_();
      charon_(charon_ &amp;orig);
      ~charon_();
      void run();
    };
  }
  
  
  #endif  /* CHARON_H */
  </code></pre>
  <p>These are the constructors / cpp files.</p>
  <pre><code>charon.cpp
  #include &lt;iostream&gt;
  //#include &lt;boost/thread.hpp&gt;
  //#include &lt;boost/date_time.hpp&gt;
  #include &quot;../headers/charon.h&quot;
  
  using namespace std;
  using namespace charon;
  using namespace chio;
  
  namespace charon
  {
    charon_::charon_(){
      engine_input = chio::chin_((charon_*)this);
    }
  };
  
  //^^charon.cpp^^
  ---------
  //chin.cpp
  
  #include &lt;iostream&gt;
  #include &lt;borland/conio.h&gt;
  #include &lt;ncurses.h&gt;
  #include &lt;deque&gt;
  #include &quot;../headers/charon.h&quot;
  
  using namespace std;
  using namespace charon;
  using namespace chio;
  namespace chio
  {
    chin_::chin_(charon::charon_&amp; handle) {
      engine = handle;
    }
    chin_::~chin_() {
    }
  }
  </code></pre>
  <p>And for the finale, I personally hate reading so I've been putting off just asking all this of anybody. So if you have come this far you probably want this too.</p>
  <pre><code>&quot;/usr/bin/gmake&quot; -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
  gmake[1]: Entering directory `/home/josh/Projects/Maze/Charon'
  &quot;/usr/bin/gmake&quot;  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/charon
  gmake[2]: Entering directory `/home/josh/Projects/Maze/Charon'
  mkdir -p build/Debug/GNU-Linux-x86/sys
  rm -f build/Debug/GNU-Linux-x86/sys/charon.o.d
  g++    -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/sys/charon.o.d -o build/Debug/GNU-Linux-x86/sys/charon.o sys/charon.cpp
  In file included from sys/charon.cpp:4:0:
  sys/../headers/charon.h:17:9: error: redefinition of ‘class charon::charon_’
  sys/../headers/chio.h:86:9: error: previous definition of ‘class charon::charon_’
  sys/charon.cpp:12:20: error: definition of implicitly-declared ‘charon::charon_::charon_()’
  gmake[2]: *** [build/Debug/GNU-Linux-x86/sys/charon.o] Error 1
  gmake[2]: Leaving directory `/home/josh/Projects/Maze/Charon'
  gmake[1]: *** [.build-conf] Error 2
  gmake[1]: Leaving directory `/home/josh/Projects/Maze/Charon'
  gmake: *** [.build-impl] Error 2
  </code></pre>
  <p>I would be simply glad to have an answer to my simpler version. I have run out of ideas to fix the compile errors and I have flipped through my huge C++ reference verifying everything I can think of. All the syntax looks to be correct, I think it is just that I have yet to specifically learn how to manipulate the compiler to do things like this.</p>
  <p>I don't know, I am probably just rambling now. This has been frustrating me for the last 3 days at least.</p>