fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A
  5. {
  6. static int x;
  7. };
  8.  
  9. template<class>
  10. struct S
  11. {
  12. int& get() { return A::x; }
  13. };
  14.  
  15. int A::x = 0;
  16.  
  17. int main()
  18. {
  19. S<int> i1, i2;
  20. S<long> l;
  21.  
  22. cout << i1.get() << " " << i2.get() << " " << l.get() << "\n";
  23. i1.get()++;
  24. cout << i1.get() << " " << i2.get() << " " << l.get() << "\n";
  25. }
Success #stdin #stdout 0s 4288KB
stdin
Standard input is empty
stdout
0 0 0
1 1 1