📜  c++ 公共继承未得到保护 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:54.479000             🧑  作者: Mango

代码示例1
class A 
{
public:
    int x;
protected:
    int y;
private:
    int z;
};

class B : public A
{
    // x is public
    // y is protected
    // z is not accessible from B
};

class C : protected A
{
    // x is protected
    // y is protected
    // z is not accessible from C
};

class D : private A    // 'private' is default for classes
{
    // x is private
    // y is private
    // z is not accessible from D
};