function - C++ returns objects by value -
the topic pretty in title of question. saw in meyrses book "effective c++":
the fact c++ returns objects value
what mean , how c++ standard supports message? instanance, have this:
int foo() { int = 1; return a; }
that's pretty clear, phrase mean returns copy of value stored in local variable. consider this:
int& foo() { int = 1; return a; }
a compiler should warn returning reference local variable. how "returning value fact" apply example?
meyers correct in main, though have take wording pinch of salt when dealing references. @ level of abstraction, here you're passing reference "by value".
but he's trying that, beyond that, c++ passes value default, , contrasts languages such java in objects chucked around reference semantics instead.
in fact, 1 could argue passage doesn't apply code @ all, because reference not "object".
Comments
Post a Comment