fork download
  1. #include <iostream>
  2.  
  3. template<typename Strategy>
  4. struct Interface
  5. {
  6. public:
  7. void call()
  8. {
  9. Strategy().call();
  10. }
  11. };
  12.  
  13. struct Flyable
  14. {
  15. public:
  16. void call()
  17. {
  18. std::cout << "flyable" << std::endl;
  19. }
  20. };
  21.  
  22. struct Reachable
  23. {
  24. public:
  25. void call()
  26. {
  27. std::cout << "reachable" << std::endl;
  28. }
  29. };
  30.  
  31. int main()
  32. {
  33. Interface<Flyable>().call();
  34. Interface<Reachable>().call();
  35. }
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
flyable
reachable