fork download
  1. #include <iostream>
  2.  
  3. template <typename T> struct Foo
  4. {
  5. void print();
  6. };
  7.  
  8. template <typename T> void Foo<T>::print()
  9. {
  10. std::cout << "Generic Foo<T>::print()\n";
  11. }
  12.  
  13. template <> void Foo<int>::print()
  14. {
  15. std::cout << "Specialized Foo<int>::print()\n";
  16. }
  17.  
  18. int main()
  19. {
  20. Foo<char> x;
  21. Foo<int> y;
  22.  
  23. x.print();
  24. y.print();
  25. }
  26.  
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
Generic Foo<T>::print()
Specialized Foo<int>::print()