Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) Private inheritance

 

Private inheritance is an uncommonly used (of three) modes of inheritance. Private inheritance denotes a 'is-implemented-in-terms-of' relationship between derived class and base class [1]. Private inheritance is usually inferior to composition [1].

 

There are no real-world examples for Private inheritance, as it means nothing during software design, only during software implementation [1]. In the example below Widget is not a kind of Timer, but it uses some of the features of Timer.

 

struct Widget : private Timer //A derived class, private inheritance
{

};

 

 

 

 

 

References

 

  1. Scott Meyers. Effective C++ (3rd edition).ISBN:0-321-33487-6. Item 39: 'Use private inheritance judiciously'

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict