#include <iostream> using namespace std; class A { protected: int x; }; class B { public: static void m() { A foo; cout << foo.x << endl; } }; int main() { B::m(); return 0; }
Standard input is empty
prog.cpp: In static member function ‘static void B::m()’: prog.cpp:13:15: error: ‘int A::x’ is protected within this context cout << foo.x << endl; ^ prog.cpp:6:6: note: declared protected here int x; ^
Standard output is empty