vendredi 28 octobre 2016

C++ 11 usage unclear

In the following C++ code what does " double (*) double " mean ? What kind of a return type it is ?

auto get_fun(int arg) -> double (*)(double) // same as: double (*get_fun(int))(double)
{
    switch (arg)
    {
        case 1: return std::fabs;
        case 2: return std::sin;
        default: return std::cos;
    }
}

Aucun commentaire:

Enregistrer un commentaire