fork download
  1. #include <iostream>
  2. #include <complex>
  3.  
  4. template<class T>
  5. class cc {
  6. template <typename TT>
  7. void print(const TT&v) { std::cout << v << std::endl ;}
  8.  
  9. template <typename TT>
  10. void print(const std::complex<TT>& c) { std::cout << "complex " << c << std::endl; }
  11.  
  12. public:
  13. void foo() { print(v); }
  14.  
  15. T v ;
  16. };
  17.  
  18. int main()
  19. {
  20. cc< std::complex<double> > r ;
  21. cc<double> r2 ;
  22.  
  23. r.foo() ;
  24. r2.foo() ;
  25. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
complex (0,0)
0