fork(3) download
  1. #include <iostream>
  2.  
  3.  
  4. template<typename> class FirstClass;
  5. template<typename> class SecondClass;
  6.  
  7. template <typename T>
  8. class FirstClass {
  9.  
  10. public:
  11. bool convert(const FirstClass<T>& f) { std::cout << "f2f\n"; }
  12. bool convert(const SecondClass<T>& s){ std::cout << "f2s\n"; }
  13.  
  14. };
  15.  
  16.  
  17. template <typename T>
  18. class SecondClass {
  19.  
  20. public:
  21. bool convert(const FirstClass<T>& f){ std::cout << "s2f\n"; }
  22. bool convert(const SecondClass<T>& s){ std::cout << "s2s\n"; }
  23.  
  24. };
  25.  
  26. int main()
  27. {
  28. FirstClass<int> f;
  29. SecondClass<int> s;
  30.  
  31. f.convert(f);
  32. f.convert(s);
  33. s.convert(f);
  34. s.convert(s);
  35.  
  36. }
Success #stdin #stdout 0s 2884KB
stdin
Standard input is empty
stdout
f2f
f2s
s2f
s2s