I want to know if my understanding of temporary objects and returning by value is correct. So consider next code:
int function()
{
int value = 0;
/*
Some calculations
*/
return value;
}
int main(int argc, char *argv[])
{
int i = function();
return 0;
}
So when we call function
in main
does temporary object with scope of expression is created and value of return expression which resides in stack gets copied into it? So total number of copying in expression int i = function();
will be 2?