fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. template<class T, int N>
  7. int Val = 3;
  8.  
  9. template<>
  10. int Val<int,0> = 5;
  11.  
  12.  
  13. template<int N>
  14. int Val<char,N> = N;
  15.  
  16.  
  17. template<class T, int N>
  18. class Test
  19. {
  20. public:
  21. void method()
  22. {
  23. cout << Val<T,N> << endl;
  24. }
  25. };
  26.  
  27. int main(int argc, const char * argv[])
  28. {
  29. Test<int,0> t1;
  30. t1.method();
  31. Test<int,5> t2;
  32. t2.method();
  33. Test<char,7> t3;
  34. t3.method();
  35. }
  36.  
  37.  
  38.  
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
5
3
7