# public, protected and private inheritance
```cpp=
// Source: https://www.programiz.com/cpp-programming/public-protected-private-inheritance
class Base {
public:
int x;
protected:
int y;
private:
int z;
};
class PublicDerived: public Base {
// x is public
// y is protected
// z is not accessible from PublicDerived
};
class ProtectedDerived: protected Base {
// x is protected
// y is protected
// z is not accessible from ProtectedDerived
};
class PrivateDerived: private Base {
// x is private
// y is private
// z is not accessible from PrivateDerived
};
class DefaultInheritance: /*private*/ Base {
};
struct DefaultInheritance: /*public*/ Base {
};
```