Ralf Gerlich wrote:
> "const string&" would only make sense if a string was returned which is
> typically stored in the object and should _not_ be copied, e.g. in a
> getter-method.

Or rather: I was wondering why a getter method would have to return a
reference to a local variable, until I looked at the source code
properly and found out that this thing is actually delegating the call
to FGAirport, in which getId() returns a simple string. So maybe it
would also be a good idea to have that return "const string&" as well.
Might save a few copying operations (even though FGAirport::getId is
probably inlined anyway in most cases, just not here due to the delegation).

I consider this "const T&" thing good practice if all you want is read
only access to a member variable via a getter method and the type of the
member might otherwise require copies to be created.

Cheers,
Ralf

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to