$ cat inheritance.cpp
#include
using namespace std;
class A { };
class B : private A { };
int main() {
A* ab = new B;
}
$
$ g++ inheritance.
private inheritance should only change how the members of class B are visible to the outside world
It does. And if
A* p = new B;
were allowed, then the inherited members of any B
could be accessed from the outside world, just by making a A*
. Since they're privately inherited, that access is illegal, and so is the upcast.