Use a pointer to member function:
struct Foo
{
void f(int, int) {}
void g(int, int) {}
void execute((Foo::*ptmf)(int, int), int a, int b)
{
// invoke
(this->*ptmf)(a, b);
}
};
Usage:
Foo x;
x.execute(&Foo::f, 1, 2); // calls x.f(1, 2)
x.execute(&Foo::g, 2, 1); // calls x.g(2, 1)
These pointers work as expected with virtual functions.