jeudi 14 juillet 2022

RVALUE reference variables and rvalue reference variables returned by the function [duplicate]

void fcn(int&& a)
{

}
int&& reti()
{
    return 3;
}

int main()
{
    int&& a = 3;
    fcn(a);    //error
    fcn(reti()); //right
    return 0;
}

why does the first call is error and the second call is right?they are all the int&& type.

Aucun commentaire:

Enregistrer un commentaire