Mail Archives: djgpp/1997/07/16/06:44:34
scochran AT shoalsnet DOT com wrote:
> void randomxy(int &x, int &y) // using refrences speeds it up by using
> the
> actual varibles
Using references are no faster than using pointers, as they are
functionally equivalent, and only represent a stylistic difference.
And, if I may interject a stylistic suggestion here, using references in
this way is in general not so hot of an idea. References are useful for
very specific circumstances; this is not one of them. Wherever possible,
one should stick with C's pass-by-value mandate, thus making it clear to a
caller what will be changed and what will not.
Speaking from experience, when one uses too many non-const references just
for the sake of _using_ them, it muddies the whole issue of, when calling
a function, what will get affected outside of the calling function and
what will not. This can lead to a big headache.
--
Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com
Alcyone Systems / web / http://www.alcyone.com/max/
San Jose, California, United States / icbm / 37 20 07 N 121 53 38 W
\
"All the gods are dead / except the god of war."
/ Eldridge Cleaver
- Raw text -