fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Cat
  5. {
  6. static void play(int value)
  7. {
  8. std::cout << "cat plays with int " << value;
  9. }
  10.  
  11. static void play(std::string value)
  12. {
  13. std::cout << "cat plays with string " << value;
  14. }
  15.  
  16. template <typename Type>
  17. static void play(Type &value)
  18. {
  19. Type::play(value);
  20. }
  21. };
  22.  
  23.  
  24. struct Dog
  25. {
  26. static void play(Dog &value)
  27. {
  28. std::cout << "cat plays with dog";
  29. }
  30. };
  31.  
  32. int main() {
  33. // your code goes here
  34. Cat cat;
  35. Dog dog;
  36. //cat.play(1);
  37. cat.play(dog);
  38. return 0;
  39. }
Success #stdin #stdout 0s 15224KB
stdin
Standard input is empty
stdout
cat plays with dog