fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template<typename T, typename U>
  6. struct Node
  7. {
  8. void function() { cout << "Non-specialized version" << endl; }
  9. };
  10.  
  11. template<typename U>
  12. void Node<int, U>::function() { cout << "Specialized version" << endl; }
  13.  
  14. int main()
  15. {
  16. Node<int, char> a;
  17. Node<int, int > b;
  18. a.function();
  19. b.function();
  20. return 0;
  21. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:12: error: invalid use of incomplete type ‘struct Node<int, U>’
prog.cpp:7: error: declaration of ‘struct Node<int, U>’
stdout
Standard output is empty