On Dienstag 25 Oktober 2005 21:33, Frederic Bouvier wrote:
> I am not a big fan of functions that return pointers or references on
> their current state. That leads to mysterious errors when the object
> goes out of scope before the pointer or the reference. I think this kind
> of optimisation is very dangerous and should be avoided IMO.
No, obviously not.
You would use that like

Point3D pt = obj.GetPos();

where the const ref is directly passed into the constructor of pt. No problem 
at all.
If you don't need a temporary copy, you can with zero cost just use 
obj.GetPos() multiple times without creating multiple temporary copies of the 
return value.

As long as the returned object is implemented const correct, returning a const 
ref by a const getter function is the prefered way to do.

  Greetings

        Mathias

-- 
Mathias Fröhlich, email: [EMAIL PROTECTED]

_______________________________________________
Flightgear-devel mailing list
[email protected]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d

Reply via email to