fork(5) download
  1. #include <iostream>
  2.  
  3. template <typename T>
  4. struct base {
  5. void foo() { std::cout << "generic" << std::endl; }
  6. void bar() { std::cout << "bar" << std::endl; }
  7. };
  8.  
  9. /*
  10. template <>
  11. void base<int>::foo() // specialize only one member
  12. {
  13.   std::cout << "int" << std::endl;
  14. }
  15. */
  16. template <>
  17. struct base<int> {
  18. void baz() { std::cout << "baz" << std::endl; }
  19. }; // error
  20.  
  21. int main() {
  22. base<int> i;
  23. i.baz();
  24. // i.foo(); // int
  25. // i.bar(); // bar
  26. }
Success #stdin #stdout 0s 2724KB
stdin
Standard input is empty
stdout
baz