title: How to resolve this header include loop?
body: <p>Hi I already read similar questions about this topic, but I coudn't resolve my problem.
  I think I have to do a forward declaration so I tried the following.</p>
  
  <p>I have three classes A, B and InterfaceA</p>
  
  <p>Defintion InterfaceA</p>
  
  <pre><code>#ifndef INTERFACE_A_H
  #define INTERFACE_A_H
  #include "B.h"
  
  namespace Example
  {
    class B; // Forward declaration?
    class InterfaceA
    {
       Example::B test;
  
     };
  
  }
  
  #endif 
  </code></pre>
  
  <p>Definiton class A</p>
  
  <pre><code>#ifndef A_H
  #define A_H
  #include "InterfaceA.h"
  namespace Example
  {
    class A : public Example::InterfaceA
    {
  
    };
  }
  #endif
  </code></pre>
  
  <p>Defintion class B</p>
  
  <pre><code>#ifndef B_H
  #define B_H
  #include "A.h"
  
  namespace Example
  {
    class A; // Forward declaration?
    class B
    {
       Example::A test;
    };
  
  }
  
  #endif
  </code></pre>
  
  <p>main </p>
  
  <pre><code>#include "A.h"
  #include "B.h"
  int main()
  {
    Example::A a;
    Example::B b;
  }
  </code></pre>
  
  <p>I get the following error in visual studio:</p>
  
  <p>'Example::B::test' uses undefined class 'Example::A'</p>
  
  <p>Edit:
  Thank you so far, for all the help. It was very helpful. I think my problem was that I had a very poor design in my real project. I will change that.</p>
  
  <p>Beside that I have now a better understanding for forward declarations :-)</p>