fork(1) download
  1. #include <iostream>
  2.  
  3. class A
  4. {
  5. private:
  6. int x;
  7.  
  8. public:
  9. static void method(A);
  10. };
  11.  
  12. void method(A a)
  13. {
  14. a.x= 5;
  15. std::cout << a.x;
  16. }
  17.  
  18. int main()
  19. {
  20. A a;
  21. A::method(a);
  22. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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;
                     ^
stdout
Standard output is empty