Originally Posted by
jlewand
The question then becomes: for integers, is there any reason to use the first example of * references vs. the latter, seemingly more concise, & references?
I consider it a bug to declare a function parameter (in C++ obviously) as a reference (with &) if the value is modified in the function. The problem is, you can't tell by looking at the function call if it is pass by reference or pass by value--you have to go back and look at the function or its prototype or just remember. And there are far too many things to remember already.
I've taken to commenting other people's code which I chance to touch, and my own code if I have to call such a function. I make the call look like this:
Code:
int func(int& var); // Declared somewhere like this
x = func(/*&ref*/var); // My comment draws attention to the gotcha