fork download
  1. #include <functional>
  2. #include <iostream>
  3.  
  4. class Animation
  5. {
  6. public:
  7. Animation(std::function<void()>&& onCompleted) : whenCompleted(onCompleted) {}
  8. std::function<void()> whenCompleted;
  9.  
  10. void startAnimation() { animationEnded(); }
  11. void animationEnded() { whenCompleted(); }
  12. };
  13.  
  14. int main()
  15. {
  16. Animation score{[](){ std::cout << "all done"; }};
  17. score.startAnimation();
  18. }
Success #stdin #stdout 0s 4940KB
stdin
Standard input is empty
stdout
all done