title: Consistently defining C++ class members as unique pointers;
body: <p>In C++ it's common to see things such as:</p>
  
  <p>Header of class C</p>
  
  <pre><code>//== C.h ==//
  #pragma once
  #include "B.h"
  
  class C
  {
      B b;
  };
  </code></pre>
  
  <p>Header of class B</p>
  
  <pre><code>//== B.h ==//
  #pragma once
  #include "A.h"
  
  class B
  {
      A a;
  };
  </code></pre>
  
  <p>Header of class A</p>
  
  <pre><code>//== A.h ==//
  #pragma once
  
  class A
  {
  
  };
  </code></pre>
  
  <p>Because <code>C.h</code> includes <code>B.h</code>, and <code>B.h</code> includes <code>A.h</code>; <code>C.h</code> ends up knowing implementation details about <code>A.h</code>. In this case the headers are included only three levels deep, but in large projects including one header can quickly lead to the inclusion of hundreds of additional headers. Also resulting in long compile times.</p>
  
  <p>In C++ 11 I could declare the headers as following:</p>
  
  <p>Header of class C:</p>
  
  <pre><code>//== C.h ==//
  #pragma once
  #include &lt;memory&gt;
  
  // proto
  class B;
  
  class C
  {
      std::unique_ptr&lt;B&gt; b;
  };
  </code></pre>
  
  <p>Header of class B</p>
  
  <pre><code>//== B.h ==//
  #pragma once
  #include &lt;memory&gt;
  
  // proto
  class A;
  
  class B
  {
      std::unique_ptr&lt;A&gt; a;
  };
  </code></pre>
  
  <p>Header of class A</p>
  
  <pre><code>//== A.h ==//
  #pragma once
  
  class A
  {
  
  };
  </code></pre>
  
  <p>When replacing all members (class, struct) with smart pointers, I can include <code>C.h</code> without having to know the implementation of class B. Every cpp file now only has to know about it's members, without having to know about the memory layout of it's members.</p>
  
  <p>My question would be:</p>
  
  <ul>
  <li>Is it good design practice (a good idea) to replace all class members, that are either class and struct, with unique pointers? Are their additional pro's or cons ?</li>
  </ul>