title: Inheritance: 'A' is an inaccessible base of 'B'
body: <pre><code>$ cat inheritance.cpp 
  #include &lt;iostream&gt;
  
  using namespace std;
  
  class A { };
  class B : private A { };
  
  int main() {
      A* ab = new B;
  }
  $
  $ g++ inheritance.cpp
  inheritance.cpp: In function 'int main()':
  inheritance.cpp:9: error: 'A' is an inaccessible base of 'B'
  $
  </code></pre>
  <p>I just do not understand this error.</p>
  <p>As I understand, and as <a href="http://www.learncpp.com/cpp-tutorial/115-inheritance-and-access-specifiers/" rel="noreferrer">this tutorial</a> confirms, <code>private</code> inheritance should only change how the members of <code>class B</code> are visible to the outside world.</p>
  <p>I think the private specifier is doing more than just change visibility of <code>class B</code> members here.</p>
  <ul>
  <li>Why do I get this error when inheriting and what does it mean?</li>
  <li>Basically what is wrong with allowing this type of code in C++? Looks totally harmless.</li>
  </ul>