fork download
  1. #include <iostream>
  2. #include <functional>
  3.  
  4. class Window
  5. {
  6. public:
  7. void ProcessMessage(std::function<int()> create, std::function<int()> update)
  8. {
  9. create();
  10. update();
  11. }
  12. };
  13.  
  14. class App
  15. {
  16. private:
  17. Window win;
  18.  
  19. private:
  20. int OnUserCreate()
  21. {
  22. std::cout << "OnUserCreate() called" << std::endl;
  23. return 1;
  24. }
  25.  
  26. int OnUserUpdate()
  27. {
  28. std::cout << "OnUserUpdate() called" << std::endl;
  29. return 1;
  30. }
  31.  
  32. public:
  33. void Run()
  34. {
  35. win.ProcessMessage(
  36. [this](){ return this->OnUserCreate(); },
  37. [this](){ return this->OnUserUpdate(); }
  38. );
  39. }
  40. };
  41.  
  42. int main()
  43. {
  44. App app;
  45. //while (true)
  46. {
  47. app.Run();
  48. }
  49. }
Success #stdin #stdout 0.01s 5400KB
stdin
Standard input is empty
stdout
OnUserCreate() called
OnUserUpdate() called