Is friendship inherited in C++?

后端 未结 3 1120
[愿得一人]
[愿得一人] 2021-02-07 12:54

Suppose I have a Base class:

class Base {
    friend SomeOtherClass;
};

And there is another (different) class that inherits from

3条回答
  •  长情又很酷
    2021-02-07 13:19

    In principle, a derived class inherits every member of a base class except:

    * its constructor and its destructor
    * its operator=() members
    * its friends
    

    So, no. Friends are not inherited.

提交回复
热议问题