title: Class name does not name a type in C++
body: <p>I just started programming in C++, and I've tried to create 2 classes where one will contain the other.</p>
  
  <p>File <code>A.h</code>:</p>
  
  <pre><code>#ifndef _A_h
  #define _A_h
  
  class A{
      public:
          A(int id);
      private:
          int _id;
          B _b; // HERE I GET A COMPILATION ERROR: B does not name a type
  };
  
  #endif
  </code></pre>
  
  <p>File <code>A.cpp</code>:</p>
  
  <pre><code>#include "A.h"
  #include "B.h"
  #include &lt;cstdio&gt;
  
  A::A(int id): _id(id), _b(){
      printf("hello\n the id is: %d\n", _id);
  }
  </code></pre>
  
  <p>File <code>B.h</code>:</p>
  
  <pre><code>#ifndef _B_h
  #define _B_h
  
  class B{
      public:
          B();
  };
  #endif
  </code></pre>
  
  <p>File <code>B.cpp</code>:</p>
  
  <pre><code>#include "B.h"
  #include &lt;cstdio&gt;
  
  B::B(){
      printf("this is hello from B\n");
  }
  </code></pre>
  
  <p>I first compile the B class and then the A class, but then I get the error message:</p>
  
  <blockquote>
    <p>A.h:9: error: ‘B’ does not name a type</p>
  </blockquote>
  
  <p>How do I fix this problem?</p>