Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

protected inheritance

Tags:

c++

Why protected and private inheritance are defined and proposed? I understand some cases private inheritance could be used but it is not recommended. How about protected inheritance?

Can anyone offer me an situation in which protected inheritance is a choice?

I rarely see this.

Thanks so much!

like image 731
skydoor Avatar asked Jan 19 '10 02:01

skydoor


1 Answers

Private inheritance is usually used for mixins---where people inherit to get functionality from the base class, rather than because of "is-a" inheritance.

Protected inheritance can also be used for mixins, where the mixed-in functionality is to be available to downstream classes too.

like image 52
Chris Jester-Young Avatar answered Sep 27 '22 02:09

Chris Jester-Young