access private members in inheritance

后端 未结 6 1402
余生分开走
余生分开走 2021-01-31 17:23

I have a class A, which have a field val declared as private. I want to declare a class B, that inherit from A and have an access to val. Is there a way to do it on C++?

<
6条回答
  •  無奈伤痛
    2021-01-31 17:49

    It is doable as describe in this Guru of the Week - GotW #76 - Uses and Abuses of Access Rights. But it's should be considered a last resort.

提交回复
热议问题