title: C++ 'Ptr' in 'class B' does not name a type error in typedef'ed shared_ptr
body: <p>I want to use typedef'ed shared_ptr object in both class A and class B.</p>
  
  <p>I am getting compilation error - 'Ptr' in 'class B' does not name a type error'
  although i am forward declaring the class.</p>
  
  <p>Here is my setup :</p>
  
  <p><strong>A.h</strong></p>
  
  <pre><code>#pragma once
  #include&lt;memory&gt;
  
  class B;//Forward Declaration
  
  class A
  {
  public:
      typedef std::shared_ptr&lt;A&gt; Ptr;
      B::Ptr get_b_ptr();
  };
  </code></pre>
  
  <p><strong>B.h</strong></p>
  
  <pre><code>#pragma once
  #include&lt;memory&gt;
  
  class A;//Forward Declaration
  
  class B
  {
  public:
      typedef std::shared_ptr&lt;B&gt; Ptr;
      A::Ptr get_a_ptr();
  };
  </code></pre>
  
  <p><strong>A.cpp</strong></p>
  
  <pre><code>#include&lt;A.h&gt;
  #include&lt;B.h&gt;
  
  B::Ptr A::get_b_ptr()
  {
      B::Ptr bptr;
      return bptr;
  }
  </code></pre>
  
  <p><strong>B.cpp</strong></p>
  
  <pre><code>#include&lt;B.h&gt;
  #include&lt;A.h&gt;
  
  A::Ptr B::get_a_ptr()
  {
      A::Ptr aptr;
      return aptr;
  }
  </code></pre>
  
  <p><strong>Test.cpp</strong></p>
  
  <pre><code>#include&lt;A.h&gt;
  #include&lt;B.h&gt;
  int main()
  {
      A::Ptr ptr1;
      B::Ptr ptr2;
  
      return 0;
  }
  </code></pre>
  
  <p>I am getting following compilation error:</p>
  
  <p>A.h:10:5:'Ptr' in 'class B' does not name a type</p>