How to make a derived class access the private member data?

前端 未结 5 879
忘掉有多难
忘掉有多难 2021-02-06 03:42

I\'m stuck with a c++ problem. I have a base class that has a self referential object pointer inside the private visibility region of the class. I have a constructor in the base

5条回答
  •  一生所求
    2021-02-06 04:04

    Derived class can not access the private members of it's base class. No type of inheritance allows access to private members.

    However if you use friend declaration you can do that.

提交回复
热议问题