1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | class A { void foo(); friend class C; }; class B : private A { }; class C { void bar() { B b; b.foo(); } }; int main() { } |
CmNsYXNzIEEgewogICB2b2lkIGZvbygpOwogICAKICAgZnJpZW5kIGNsYXNzIEM7Cn07CgpjbGFzcyBCIDogcHJpdmF0ZSBBIHsKfTsKCmNsYXNzIEMgewogICB2b2lkIGJhcigpIHsgQiBiOyBiLmZvbygpOyB9Cn07CgppbnQgbWFpbigpIHsKfQ==
prog.cpp: In member function ‘void C::bar()’: prog.cpp:3: error: ‘void A::foo()’ is private prog.cpp:12: error: within this context prog.cpp:12: error: ‘A’ is not an accessible base of ‘B’
-
result: Compilation error (maybe you wish to see an example for C++ 4.7.2)


