In The C++ Programming Language, 4th Edition, at §20.5.2 "Access to Base Class" (page 605), it says (regarding private inheritance):
private bases are most useful when defining a class by restricting the interface to a base so that stronger guarantees can be provided.For example, B is an implementation detail of Z .The Vector of pointers template that adds type checking to its Vector base from §25.3 is a good example.
It's not clear what Bjarne Stroustrup is trying to say here. How can be a class be defined by restricting "the interface" to a base? What does he mean by "stronger guarantees"?
Lets take a very simple example:
The
privateinheritance restricts access to the members of the base class. Even if theA::amember variable ispublic, due to theprivateinheritance it becomesprivatein the sub-classB.