Skip to content

Instantly share code, notes, and snippets.

@kkabdol
Created November 9, 2016 09:28
Show Gist options
  • Select an option

  • Save kkabdol/9b3682d2c944a1b9418bd8d4b90a1c26 to your computer and use it in GitHub Desktop.

Select an option

Save kkabdol/9b3682d2c944a1b9418bd8d4b90a1c26 to your computer and use it in GitHub Desktop.
Access Modifiers
// From Kirill V. Lyadvinsky
// http://stackoverflow.com/questions/860339/difference-between-private-public-and-protected-inheritance
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
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment