W
Wayne Shu
Hi everyone:
I am reading Bjarne Stroustrup's The C++ Programming
Language(Special Edition).
In section 7.3, bs wrote "Like the semantics of argument passing,
the semantics of function value return are identical to the semantics
of initialization. A return statement is considered to initialize an
unnamed variable of the returned type."
Is the *unnamed variable* here always create when we call a
function?
For instance, there is a function foo,
int foo(int i)
{
return i*i;
}
when we call it,
int i = foo(5);
Is the above statement mean the following code(not legal in c++)
int tmp = foo(5); // tmp here is the *unnamed variable* bs referred.
int i = tmp;
Even for the build-in types, it is ineffective, why need the *unnamed
variable*?
Regards.
I am reading Bjarne Stroustrup's The C++ Programming
Language(Special Edition).
In section 7.3, bs wrote "Like the semantics of argument passing,
the semantics of function value return are identical to the semantics
of initialization. A return statement is considered to initialize an
unnamed variable of the returned type."
Is the *unnamed variable* here always create when we call a
function?
For instance, there is a function foo,
int foo(int i)
{
return i*i;
}
when we call it,
int i = foo(5);
Is the above statement mean the following code(not legal in c++)
int tmp = foo(5); // tmp here is the *unnamed variable* bs referred.
int i = tmp;
Even for the build-in types, it is ineffective, why need the *unnamed
variable*?
Regards.