fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Test
  6. {
  7. int x;
  8. public:
  9. Test() : x(0) {}
  10. void print() { cout << x << endl; }
  11. void access(Test& t) { t.x = 10; }
  12. };
  13.  
  14. int main()
  15. {
  16. Test t1, t2;
  17. t1.access(t2);
  18. t2.print();
  19. return 0;
  20. }
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
10