Protoman said:
When would you return a const reference/pointer from a function instead
of either the object itself,
I would return a const reference/pointer to avoid "premature pessimization"
but only if the object is alive even after the function returns.
If the object is non-copyable there is no other way than returning a
reference/pointer.
or a non constreference/pointer?
If the caller should be allowed to modify the object through the returned
reference/pointer.
And when
would you need to return a reference or pointer at all, instead of the
object itself?
You cannot return the object itself. You can either return a
reference/pointer to it, or you can return a copy of it.
When you need to work on a specific object, not a copy of it, you have to
return a reference/pointer.
Ali
--
Plug: ACCU's Silicon Valley Chapter meets on second Tuesdays. The meetings
are open to public and free of charge. Please come tonight for a talk on
Ada:
http://accu-usa.org/index.html