0

I am trying to create a function and return it from within another function, in the following way:

std::function<double(double)> to_equation(std::vector<double> coefficients)
{
    double f(double t)
    {
        auto total = 0.0;
        for (int i = 0; i < coefficients.length(); i++)
        {
            auto c = coefficients[i];
            total += c * t ** i;
        }
        return total
    };

    return f;
}

the code does however not work. What did I do wrong?

Rakete1111
  • 47,013
  • 16
  • 123
  • 162
Oblomov
  • 8,953
  • 22
  • 60
  • 106

0 Answers0