fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. template<class T>
  5. class Game
  6. {
  7. public:
  8.  
  9. //Game-related
  10. template <typename U>
  11. U processEvents(std::string input);
  12.  
  13. template <typename U>
  14. void display(U action);
  15. };
  16.  
  17. template<class T>
  18. template<class U>
  19. U Game<T>::processEvents(std::string input)
  20. {
  21. std::cout << "Game::processEvents(\"" << input << "\")\n";
  22. return U();
  23. //
  24. }
  25.  
  26. template<class T>
  27. template<class U>
  28. void Game<T>::display(U action)
  29. {
  30. std::cout << "Game::Display(" << action << ")\n";
  31. }
  32.  
  33. int main()
  34. {
  35. Game<int> game;
  36.  
  37. int value = game.processEvents<int>("string1");
  38. std::string val2 = game.processEvents<std::string>("string2");
  39. game.display(69);
  40. game.display("another string");
  41. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
Game::processEvents("string1")
Game::processEvents("string2")
Game::Display(69)
Game::Display(another string)