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