I want to create a class with a method
class Caller
{
public:
void Invoke(const char * function_name, ...);
};
so that if I can call a variety of functions with a variable number and types of argument
void MyFunc(Caller * caller, std::vector<int> const & data)
{
caller->Invoke("doSomething", 10);
caller->Invoke("doSomethingElse", 10, 1.0f, data);
}
where the functions elsewhere are
void doSomething(int arg) {...}
void doSomethingElse(int x, float y, std::vector<int> const & z) {...}
So my 2 problems are
- How do I store pointers to functions with different signatures in a single table?
- How does the
Invoke()
method pass the required arguments to these functions?