fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. typedef void(*Delegate)();
  6.  
  7. void test(Delegate action)
  8. {
  9. action();
  10. }
  11.  
  12. int main() {
  13. int a = 0;
  14.  
  15. auto func = [&a]() // В этом место могло быть [=] или [*]
  16. {
  17. ++a;
  18. std::cout << "func: " << a ;
  19. };
  20. static auto staticFn = func;
  21.  
  22. Delegate ptr = []( ) { return staticFn(); };
  23.  
  24. test(ptr);
  25. return 0;
  26. }
Success #stdin #stdout 0s 4368KB
stdin
Standard input is empty
stdout
func: 1