On Apr 4, 9:34 am, nvangogh <
nvang...@invalid.net> wrote:
> But some people write eg: string func1(value&) -
> This was what caused the original confusion.
> A space makes the meaning clearer such as (value &).
Yes and no. :-)
Proper use of spacing (or lack thereof) makes the meaning MUCH
clearer. I have a standard that works quite well for me. When I am
given code written by others, I add/remove spacing so it conforms to
my practice.
The ampersand is a great example.
(1) When it is a prefix operator, I type it immediate to the left of
the "operated" variable (no spacing).
memset(&some_struct, 0, sizeof(some_struct));
(2) When it is a reference (postfix) I place it to the right, again
with no spacing:
SomeClass::my_function(SomeType& varname) {
}
(3) Finally when the ampersand denotes an infix operator (either one
'&' bitwise or '&&' boolean), I always use spacing on both sides:
bool isDone = condition && othercondition;
-Ramon