In a small DLL I'm working on, I need a way for the user to enter a functional definition, which is then passed to my function as an argument (PCHAR), and have this evaluated.

For example, if my function is defined thus:

double eval(PCHAR func,PCHAR vari,double val) { }

And the user calls it thus:

eval("3x+5","x",5)

It will return 20, as 3x+5=20 when x=5.

This is similar to Javascript's eval() function, but as C++ is nothing like Javascript, I doubt it'll be so easy.

Is there any way to do this? I need the user to be able to pass their custom functions to the DLL for evaluation.

If it matters, due to compatibility constraints, only PCHARs and doubles may be passed as arguments or returned, though anything goes within a function.

-IMP