On Aug 12, 3:48 pm, Wayne Shu <Wayne...@gmail.com> wrote:
> 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?
No. What do you think Bjarne meant by "is considered to
create", rather than just saying "creates"?
In general, the compiler can do anything it wants, as long as
the "observable behavior" of the program is not modified. In
this particular case, there is even special language to allow
the compiler to suppress the extra object even if doing so
changes the observable behavior.
--
James Kanze (GABI Software) email:james.ka...@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34