user supplied function

is there's a way to make a user supply for function in c++
I know it's a dump question but I was wondering
Not directly, but you could have your program take commands from the user to indirectly call functions in your program.

i.e.
1
2
3
4
5
6
7
string input;

getline(cin, input);

if (input=="clear")
clear();
//and so on 


You could also make a small scripting language that could then be interpreted by your program, but that would be more trouble than its worth for just playing around.
Fortunately, there are ready solutions to this, one of them being this -> http://www.lua.org/pil/24.html

closed account (z05DSL3A)
When you say 'user', what do you mean? The user of a library you are writing i.e. another programmer, or the end user of an application you are writing.
This isn't a dumb question, but like Grey Wolf pointed out it is an incomplete one.

You would need to have your function except a function pointer as an argument. The rest of the answer requires you to tell us more about how you plan to use it.

You can even have the end user of the executable supply a function for your program. This is messy and will probably get me flammed for suggesting it, but it is possible.
ModShop
thats totally not what i meant but thx 4 trying 2 help :)
GreyWolf///Computergeek01
I mean another usr in the runtime if possible
Then, ModShop's reply (and, consequently, mine) is what you want ;)
Last edited on
Topic archived. No new replies allowed.