假设我有一个 Base
类:
class Base {
friend SomeOtherClass;
};
还有另一个(不同的)类继承自 Base
:
class AnotherClass : public Base {}
友元也会继承吗?
最佳答案
原则上,派生类继承基类的每个成员,除了:
* its constructor and its destructor
* its operator=() members
* its friends
所以,不。 friend 不会被继承。
关于c++ - 友元是在 C++ 中继承的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/597857/