fork download
  1. #include <iostream>
  2.  
  3. struct Action {
  4. virtual void operator() () const = 0;
  5. };
  6.  
  7. // The DLL function
  8. void RunFunction(const Action &action) {
  9. action();
  10. }
  11.  
  12. // Define your function as a derived functor
  13. struct FunctionToExecute : Action {
  14. void operator() () const { std::cout << "Hello\n"; }
  15. };
  16.  
  17. int main() {
  18. // Run a function
  19. RunFunction(FunctionToExecute());
  20. }
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
Hello