Answers for "c++ public inheritance not getting protected"

C++
0

c++ public inheritance not getting protected

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
};
Posted by: Guest on May-08-2020

Code answers related to "c++ public inheritance not getting protected"

Browse Popular Code Answers by Language