#include <iostream> class A { private: int x; public: static void method(A); }; void method(A a) { a.x= 5; std::cout << a.x; } int main() { A a; A::method(a); }
Standard input is empty
prog.cpp: In function 'void method(A)':
prog.cpp:6:13: error: 'int A::x' is private
int x;
^
prog.cpp:14:8: error: within this context
a.x= 5;
^
prog.cpp:6:13: error: 'int A::x' is private
int x;
^
prog.cpp:15:21: error: within this context
std::cout << a.x;
^
Standard output is empty