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.  
  11. template<typename T>
  12. void C::f(T t)
  13. {
  14. cout << t << endl;
  15. }
  16.  
  17. template<typename T>
  18. void C::f<T*>(T* pt)
  19. {
  20. cout << "(pointer specialization) " << *pt << endl;
  21. }
  22.  
  23. int main()
  24. {
  25. C c;
  26. c.f(0);
  27. c.f(&c);
  28. return 0;
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
compilation info
prog.cpp:18:20: error: function template partial specialization ‘f<T*>’ is not allowed
prog.cpp:18:6: error: prototype for ‘void C::f(T*)’ does not match any in class ‘C’
prog.cpp:8:10: error: candidate is: template<class T> void C::f(T)
stdout
Standard output is empty