I am working on a problem in C++17 where I am building a root solver that allows the user to pass a user-defined function to the root-solving function. An example of the class is shown below for the `.cpp` file and the prototype is in the `.hpp` file.

```
// root.cpp
double RootSolver::newton(double guess, double right_side,
                          double (*func)(double),
                          double unc, int iter)
/**
Finds a specific root of a function using the Newton iteration
method

 @param guess      An initial guess for the value of the root
 @param right_side The value of the right side of the
                   function.
 @param func       The function for which the root will be
                   determined
 @param unc        The uncertainty or tolerance in the accepted
                   solution.  Defaulted to 0.001
 @param iter       The number of iterations to try before the
                   function fails.  Defaulted to 150.
 @return root
 */
{
    double x1, x2, x3, y1, y2, slope;
    x1 = guess;
    x2 = x1 + 0.0000001;
    for (int i = 0; i < iter; i++)
    {
        y1 = func(x1) - right_side;
        y2 = func(x2) - right_side;
        slope = (y2 - y1) / (x2 - x1);
        x3 = x1 - (y1 / slope);
        if (func(x3) - right_side <= unc and
            func(x3) - right_side >= -unc) return x3;
        x1 = x3;
        x2 = x1 + 0.0000001;
    }
    exit_program(iter);
}
// ================================================================
// RootSolver PRIVATE FUNCTIONS

[[noreturn]] void RootSolver::exit_program(int iter)
{
    std::string one("Function did not converge within ");
    std::string two(" iterations");
    std::cout << one << iter << two << std::endl;
    exit (EXIT_FAILURE);
}

```

The main file looks like this;

```
double func1(double x);
double func2(double x, double a, double b);
int main() {
    RootSolver q;
    double guess = 2.0;
    double right_side = 0.0;
    // This function works fine
    result = q.newton(guess, right_side, func1)

    // - Not sure how to reformat RootSolver.newton so
         I can pass it func1 as well as func2 so it can
         accept the arguments a and b
    return 0;
}

double func1(double x)
{
    return pow(x, 6) - x - 1.0;
}

double func2(double x)
{
    return pow(x, 6) - a * x - b * 1.0;
}

```

The code shown above works great for func1, since `x` is the only argument; however, I am not sure how to reformat the `RootSolver.newton` function so it will take `func1` with no arguments except `x` and accept `func2` and the arguments `a` and `b`. Does anyone know how I can pass arguments to the function `newton` such that it is not hardcoded for a specific input function?