fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class C
  5. {
  6. public:
  7. template<typename T>
  8. void f(T t)
  9. {
  10. cout << t << endl;
  11. }
  12.  
  13. template<>
  14. void f<int>(int t)
  15. {
  16. cout << "(int specialization) " << t << endl;
  17. }
  18. };
  19.  
  20. int main()
  21. {
  22. C c;
  23. c.f(0);
  24. return 0;
  25. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
compilation info
prog.cpp:13:14: error: explicit specialization in non-namespace scope ‘class C’
prog.cpp:14:22: error: template-id ‘f<int>’ in declaration of primary template
stdout
Standard output is empty