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
  • 44,719
  • 11
  • 118
  • 156
Oblomov
  • 7,935
  • 20
  • 55
  • 98

0 Answers0