Ralf Gerlich wrote: > Maybe that's a dumb question (which would be embarassing, because I > typically think of myself as a good C++ programmer), but why use a > reference in the return type anyway instead of the "real thing"? If a > copy is created anyway, the "&" doesn't have any advantage, or am I > missing something?
References can be lvalues, so it's possible to write functions whose returned valued can be assigned. The examples are usually pretty academic, but consider a sparse 2D array with a method like int& element(int x, int y); You can use this thing as element(3, 4) to get the value, but you can also use: array->element(3, 4) = 12345; to *set* the value. Cute, huh? And utterly worthless. Sane code would just use a set_element() function and be done with it instead of using a design element that even good, productive programmers don't always recognize. The older I get, the more C++ looks like a terrible, terrible mistake. Andy ------------------------------------------------------------------------- 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 [email protected] https://lists.sourceforge.net/lists/listinfo/flightgear-devel

