#include <iostream>
template <class T>
class ClassGettingExecutableFunction {
private:
void (T::*C_execute_func)();
public:
ClassGettingExecutableFunction(void (T::*execute_func)()) : C_execute_func(execute_func) {}
void SetExecuteFunc(void (T::*execute_func)()) {
C_execute_func = execute_func;
}
void Execute() {
T instance;
(instance.*C_execute_func)();
}
};
class ExampleClass {
public:
void ExampleFunction() {
std::cout << "Example function executed." << std::endl;
}
};
int main() {
ClassGettingExecutableFunction<ExampleClass> executer(0);
executer.SetExecuteFunc(&ExampleClass::ExampleFunction);
executer.Execute();
return 0;
}