fork download
  1. #include <iostream>
  2.  
  3. class A
  4. {
  5. int x;
  6. friend void f(const A &a);
  7. public:
  8. explicit A(int x_)
  9. {
  10. x = x_;
  11. }
  12. };
  13.  
  14. void f(const A &a)
  15. {
  16. std::cout << a.x << std::endl;
  17. }
  18.  
  19. int main()
  20. {
  21. A a1(9000);
  22. f(a1);
  23. A a2(100500);
  24. f(a2);
  25. return 0;
  26. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
9000
100500