C++中受保护的继承
Protected Inheritance in C++
简单代码:
class A
{
private: int a;
protected: int b;
public: int c;
};
class B : protected A
{
};
class C : protected B
{
};
我知道在B班,a将保持私有&b和c受到保护。
但我感到困惑的是,C类中的访问说明符是什么?
有了protected
继承,继承的public
成员就变成了protected
。
随着private
的继承,public
和protected
的成员变成了private
。
相关文章:
- 继承和友元函数,从基类访问受保护的成员
- 为什么继承的受保护构造函数不能公开?
- 在使用受保护和继承时无法访问在类中声明的私有成员
- 继承期间受保护成员的皮条
- 在 lambda 函数 g++-4.8 中调用继承的受保护子类型
- 在派生类中具有相同签名但继承为受保护的函数
- 为什么我无法使用受保护/私有继承访问派生实例中基类的受保护成员?
- 使从一个基类派生的类能够使用继承的受保护成员
- 为什么继承的受保护操作员=()有公共访问权限
- C :可以从类及其受保护的成员类型继承可以继承吗?
- C++对已继承的受保护类成员的未定义引用
- 如何访问多个继承类中的受保护成员
- 用受保护的继承指向基类方法
- C 继承访问受保护的数据成员
- 受保护的方法在 c++ 中继承时可以成为私有方法
- 继承公共/受保护/私有构造函数
- 虚拟继承和受保护的成员访问
- 继承受保护的函数和公共变量C++时发生多重继承编译错误
- C++继承:受保护的变量不可用
- 模板类未从另一个模板类继承受保护的变量