literal and rvalue reference

后端 未结 2 2093
半阙折子戏
半阙折子戏 2020-12-21 00:19
void test(int && val)
{
    val=4;
}

void main()
{  
    test(1);
    std::cin.ignore();    
}

Is a int is created when

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-21 01:00

    An int with the value 1 is created when test is called. Literals are typed by their form. For example, 1 is an int, 1.0 is a double, "1" is a string.

提交回复
热议问题