Created
February 16, 2017 17:23
-
-
Save piokuc/33f8135f6903b745bef14f145313b57e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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