fork(1) download
  1. #include <cstdio>
  2.  
  3. template <class Writer>
  4. class HiBye
  5. {
  6. public:
  7. void say_hi() const
  8. {
  9. Writer::writeImpl("Hi");
  10. }
  11.  
  12. void say_bye() const
  13. {
  14. Writer::writeImpl("Bye");
  15. }
  16. };
  17.  
  18. class ConsoleWriter
  19. {
  20. public:
  21. static void writeImpl(const char* str)
  22. {
  23. printf("%s\n", str);
  24. }
  25.  
  26. protected:
  27. ~ConsoleWriter() { }
  28. };
  29.  
  30. int main()
  31. {
  32. HiBye<ConsoleWriter> h;
  33. h.say_hi();
  34. return 0;
  35. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
Hi