fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct C1 {
  5. template <typename T>
  6. void g(T t);
  7.  
  8. void g(double x) {
  9. cout << "C1::g(double): " << x << endl;
  10. }
  11. };
  12.  
  13. template<>
  14. void C1::g(double x) {
  15. cout << "Member templates. C1::g(double) " << x << endl;
  16. }
  17.  
  18. int main() {
  19. C1 c;
  20. c.g(10.5); // output: C1::g(double): 10.5
  21. c.g<>(10.5); // output: Member templates. C1::g(double) 10.5
  22. return 0;
  23. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
C1::g(double): 10.5
Member templates. C1::g(double) 10.5