Ah, I love it when people advocate "do what you can get away with, and hope it won't break" rather than "apply a little more effort and do it right so you know it won't break".
Ah, I love it when people advocate "do what you can get away with, and hope it won't break" rather than "apply a little more effort and do it right so you know it won't break".
Last I checked, 4 was as much as 4, and greater than 2 and 1. Consequently, there will not be any advantage of pass by reference over a copy of some built-in types with respect to memory, which, from what I see, is Daved's point when making the distinction between class types and built-in types.It applies to all types. Built-in types, when passed by value, have to be copied and that consumes memory.
...
Last I checked, 8 was twice the value of 4. "Lightning fast" is not the same as "zero impact".
I note that even for passing a double the expense would also be "a fixed, and relatively small, upper bound", albeit possibly larger than that of pass by reference/pointer.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
Also, the double being 8 bytes long, passed as a reference will be 4 bytes, but as soon as you come to ACCESS the double the compiler will have to read the reference to find the actual double, so depending on the usage pattern, although it saves some stack-space, it doesn't necessarily save any execution time.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.