language: C++ 4.7.2 (gcc-4.7.2)
date: 324 days 1 hour ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
 
struct Action {
    virtual void operator() () const = 0;
};
 
// The DLL function
void RunFunction(const Action &action) {
    action();
}
 
// Define your function as a derived functor
struct FunctionToExecute : Action {
    void operator() () const { std::cout << "Hello\n"; }
};
 
int main() {
    // Run a function
    RunFunction(FunctionToExecute());
}