C++ - Public vs. protected vs. private inheritance

With public inheritance:

  • public members in the base class, stay public in the derived class
  • protected members in the base class, stay protected in the derived class
  • private members in the base class, are hidden to the derived class

With protected inheritance:

  • public members in the base class, become protected in the derived class
  • protected members in the base class, become protected in the derived class
  • private members in the base class, are hidden to the derived class

With private inheritance:

  • public members in the base class, become private in the derived class
  • protected members in the base class, become private in the derived class
  • private members in the base class, are hidden to the derived class

Ads by Google


Ask a question, send a comment, or report a problem - click here to contact me.

© Richard McGrath