You probably want lambda or std::function
, or std::bind
auto l_add_100 = [](double x) { return add_two_numbers(x, 100); };
std::function<double(double)> f_add_100 = [](double x) { return add_two_numbers(x, 100); }
auto b_add_100 = std::bind(add_two_numbers, std::place_holder::_1, 100);
or with non hard coded number
double y = //...
auto l_add_y = [y](double x) { return add_two_numbers(x, y); }
std::function<double(double)> f_add_y = [](double x) { return add_two_numbers(x, y); }
auto b_add_100 = std::bind(add_two_numbers, std::place_holder::_1, y);
solved Making a new function by fixing one of the input parameters [closed]