I have not been able to find the best (if any satisfactory) solution to the following issue which essentially boils down to how best to have a function (or member function) return a function (pointer).

More concretely:

I have an integration function which as one of its parameter takes a funtion of one variable (say 3+2*x), i.e. the parameter has the form double f(double);

The user can via an interface specify the coefficients to the one parameter function, let's say a and b in the equation a+b*x.

How do I construct a function which takes two parameters (a and b) as input and returns a funtion (pointer) of one variable, namely a+b*x.

OR alternatively, how do I construct a class which as it's constructor takes two parameters (a and b) and provide a means for creating and returning a function of one variable, namely a+b*x. If a+b*x is constructed as a member function, it seems I can't use this member function to pass into my integration routine? And if it is somehow possible, would it create a lot of overhead?

This must be a common sort of problem but I have not been able to find what is a good solution.