title: How to dynamic_cast in classes with circular dependency?
body: <p>I want to dynamically cast a class:</p>
  
  <blockquote>
    <p>A.h:</p>
  </blockquote>
  
  <pre><code>class A
  {
  };
  </code></pre>
  
  <blockquote>
    <p>B.h:</p>
  </blockquote>
  
  <pre><code>class B
      : public A
  {
  public:
      void foo(A *a)
      {
          C* c = dynamic_cast&lt;C*&gt;(a);
      }
  };
  </code></pre>
  
  <blockquote>
    <p>C.h:</p>
  </blockquote>
  
  <pre><code>class C
      : public A
  {
  public:
      void foo(A *a)
      {
          B* b = dynamic_cast&lt;B*&gt;(a);
      }
  };
  </code></pre>
  
  <blockquote>
    <p>main.cpp:</p>
  </blockquote>
  
  <pre><code>#include "A.h"
  #include "B.h"
  #include "C.h"
  
  int main()
  {
  }
  </code></pre>
  
  <p>When I compile, I get the following error:</p>
  
  <blockquote>
    <p>'C' : undeclared identifier </p>
  </blockquote>
  
  <p>I think it is because of circular dependency between classes <code>B</code> and <code>C</code>.
  How I can solve this problem?</p>