Question regarding built-in type variable is returned from a function
Posted
by
Chan
on Stack Overflow
See other posts from Stack Overflow
or by Chan
Published on 2011-02-20T06:20:52Z
Indexed on
2011/02/20
7:25 UTC
Read the original article
Hit count: 285
c++
Hello,
If a local object is returned in a function call, it has to do at least three steps:
1. Copy constructor is called to hold a copy.
2. Destroy local object.
3. A copy is return.
For example:
x = y + z
If x
is an integer object. A copy of y + z
should be returned, then a new object is created, then assignment operator of x
will take this object as parameter.
So my question is:
Is the same process used for built-in type such as int
, double
...? If they're not the same, how's it done?
Thanks,
Chan
© Stack Overflow or respective owner