fork download
  1. #include <functional>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. void f1(std::function<void()> callback) {
  6. std::cout << "Hello!" << endl;
  7. callback();
  8. std::cout << "Bye!" << endl;
  9. }
  10.  
  11. int main() {
  12. f1([] {
  13. std::cout << "Kimchi!" << endl;
  14. });
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
Hello!
Kimchi!
Bye!