Skip to content

Instantly share code, notes, and snippets.

@piokuc
Created February 16, 2017 17:23
Show Gist options
  • Save piokuc/33f8135f6903b745bef14f145313b57e to your computer and use it in GitHub Desktop.
Save piokuc/33f8135f6903b745bef14f145313b57e to your computer and use it in GitHub Desktop.
class B {
public:
virtual void foo() {}
};
class C : private B {
public:
void bar() { foo(); }
};
class D : public C {
public:
//void baz() { foo(); } // error: ‘B’ is not an accessible base of ‘D’
void baz() { bar(); }
};
int main()
{
C c;
//c.foo(); // error: ‘B’ is not an accessible base of ‘C’
c.bar(); // this is fine, of course
//B* bp (new C); // error: ‘B’ is an inaccessible base of ‘C’
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment