fork download
  1. #include <iostream>
  2.  
  3. struct T
  4. {
  5. mutable int x;
  6.  
  7. T() : x(0) {}
  8. };
  9.  
  10. void bar(int& x)
  11. {
  12. x = 42;
  13. }
  14.  
  15. void foo(const T& t)
  16. {
  17. bar(t.x);
  18. }
  19.  
  20. int main()
  21. {
  22. T t;
  23. foo(t);
  24. std::cout << t.x << '\n';
  25. }
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
42