fork download
  1. #include <iostream>
  2.  
  3. class Test
  4. {
  5. public:
  6.  
  7. int val;
  8.  
  9. Test(int v)
  10. {
  11. val = v;
  12. }
  13.  
  14. void operator||(Test& other)
  15. {
  16. this->val = 20;
  17. other.val = 40;
  18. }
  19. };
  20.  
  21.  
  22. int main()
  23. {
  24. Test a(50);
  25. Test b(100);
  26.  
  27. std::cout << "a: " << a.val << ", b: " << b.val << std::endl;
  28. a || b;
  29. std::cout << "a: " << a.val << ", b: " << b.val << std::endl;
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
a: 50, b: 100
a: 20, b: 40