在另一个函数中创建并返回一个函数

时间:2017-08-06 13:52:45

标签: c++

我正在尝试创建一个函数并从另一个函数中返回它,方法如下:

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;
}
然而,代码不起作用。我做错了什么?

0 个答案:

没有答案
相关问题