Calling a function from function name
Hello,
In c++, let us consider that we have a string or char* functionName and that we know the signature (output and input arguments types) of the function we want to call.
Is there a way to call this function ? I think I have to use function pointer.. But still the problem is to find the pointer of the function by using its name.
Thanks in advance,
rilpo
Re: Calling a function from function name
In short: No. C++ does not have anything corresponding to Java reflection. You need to know the address where the function is stored to call it, not it's name.
Re: Calling a function from function name
That´s not possible in C/C++. Using a std::map storing string/fn pointers pairs might be a solution, but you have to fill the map on your own. You also need a separate map for each function type (signature).
Re: Calling a function from function name
Ok thank you for this answer, also for the concept of reflection. So I will use a map.