fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class X {
  6. public:
  7. static int x;
  8. };
  9.  
  10. // Teraz X::x bedzie rowne 0.
  11. int X::x;
  12.  
  13. template <typename T>
  14. class Y {
  15. public:
  16. static int y;
  17. };
  18.  
  19. template <typename T>
  20. int Y<T>::y = 10;
  21.  
  22. // Specjalizacja wyglada tak:
  23. template<>
  24. int Y<double>::y = 20;
  25.  
  26. int main() {
  27. cout << X::x << '\n';
  28. cout << Y<int>::y << '\n';
  29. cout << Y<double>::y << '\n';
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
0
10
20