title: C++ : Forward Declaration, circular dependency, static methods
body: <p>The following code, very simple, gives me this error:</p>
  
  <blockquote>
    <p>[Error] incomplete type 'C_1' used in nested name specifier</p>
  </blockquote>
  
  <p>I have two classes which interact each other calling their own methods.
  With this code, i can't call C1::test() because it seems it's not been found.
  Any help is appreciated.</p>
  
  <p><strong>C1.h:</strong></p>
  
  <pre><code>#ifndef C1
  #define C1
  
  #include &lt;iostream&gt;
  using namespace std;
  
  #include "C2.h"
  
  class C_1{
  
      private:
  
          static C_2* c2;
      public:
  
          static void test();
  };
  
  #endif
  </code></pre>
  
  <p><strong>C1.cpp:</strong></p>
  
  <pre><code>#include "C1.h"
  
  C_2* C_1::c2=new C_2();
  
  void C_1::test(){
  
      cout &lt;&lt; "C_1 test() method called." &lt;&lt; endl;
      C_1::c2-&gt;test();
  }
  </code></pre>
  
  <p><strong>C2.h:</strong></p>
  
  <pre><code>#ifndef C2
  #define C2
  
  class C_1;
  
  class C_2{
  
      public:
  
          C_2();
          void call();
  
          void test();
  };
  #endif
  </code></pre>
  
  <p><strong>C2.cpp:</strong></p>
  
  <pre><code>#include "C2.h"
  
  C_2::C_2(){}
  
  void C_2::call(){
  
      C_1::test();
  }
  
  void C_2::test(){
  
      cout &lt;&lt; "C_2.test() method called!"  &lt;&lt; endl;
  }
  </code></pre>