Is friendship inherited in C++?

后端 未结 3 1173
[愿得一人]
[愿得一人] 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:28

    No it isn't.

    Edit: To quote from the C++ Standard, section 11.4/8

    Friendship is neither inherited nor transitive.

提交回复
热议问题