1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | class A { protected: int abc; A* ptr; }; class C : public A { }; class B : public A { public: int foo() { return ptr->abc; } }; |
Y2xhc3MgQQp7CnByb3RlY3RlZDoKICAgIGludCBhYmM7CiAgICBBKiBwdHI7Cn07CgpjbGFzcyBDIDogcHVibGljIEEKewp9OwoKY2xhc3MgQiA6IHB1YmxpYyBBCnsKcHVibGljOgogICAgaW50IGZvbygpCiAgICB7CiAgICAgICAgcmV0dXJuIHB0ci0+YWJjOwogICAgfQp9Owo=
prog.cpp: In member function ‘int B::foo()’: prog.cpp:4: error: ‘int A::abc’ is protected prog.cpp:17: error: within this context
-
result: Compilation error (maybe you wish to see an example for C++ 4.7.2)


