Function that can accept another function

I want to make a class with a function, that can accept the function of another class, with a vector of arguments. And perform the function with each of those arguments.

for example:

1
2
3
4
int double(int a)
{
    return 2*a;
}


and then it would be used like this:
doFunction(double(), std::vector<int> {2,5,4,6});

and it would return a vector of outputs(4,10,8,12)

I am unsure of of how to do this in a way it could be used for any function.
Last edited on
closed account (48bpfSEw)
search for "function pointer" in cpp

e.g.
http://www.cprogramming.com/tutorial/function-pointers.html

Topic archived. No new replies allowed.