fork download
  1. #include <iostream>
  2.  
  3. class A
  4. {
  5. public:
  6. static int something;
  7. int a;
  8. };
  9. int A::something = 42;
  10.  
  11. void fun(const A& a)
  12. {
  13. a.something = a.something + 1;
  14. }
  15.  
  16. void printa(const A& a)
  17. {
  18. std::cout << "something: " << a.something << "\na: " << a.a << "\n";
  19. }
  20.  
  21. int main()
  22. {
  23. A w;
  24. w.a = -5;
  25. printa(w);
  26. fun(w);
  27. printa(w);
  28. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
something: 42
a: -5
something: 43
a: -5