Difference between private, public, and protected inheritance

后端 未结 16 1765
灰色年华
灰色年华 2020-11-21 06:15

What is the difference between public, private, and protected inheritance in C++?

16条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-21 06:27

    Summary:

    • Private: no one can see it except for within the class
    • Protected: Private + derived classes can see it
    • Public: the world can see it

    When inheriting, you can (in some languages) change the protection type of a data member in certain direction, e.g. from protected to public.

提交回复
热议问题