Hi,
I currently have a application which needs to dynamically define a
function (post-compilation). In Lisp, this can be done by embedding a
function definition inside a string, and call eval(string). In C++, I
thought about using #define macros, like so:
#define some_function() int a = 3; int b = 5; cout << a + b << endl;
int main(int argc, char *argv[]) {
some_function();
return 0;
}
main() in this case would print out "8". The problem is that I don't
know the function definition before hand, and I need something like:
#define some_function() STRING
where STRING contains "int a = 3; int b = 5; cout << a + b <<
endl" (which can be parsed from a file, for example).
Does anyone know how to do this?
Thanks!