C ++ Link Syntax

What is the correct way to set a link. I know that both work with the compiler, but I wanted to know the correct path, since I saw both in the code base.

void Subroutine(int &Parameter) 
{ 
    Parameter=100;
}

OR

void Subroutine(int& Parameter) 
{ 
    Parameter=100;
}
+3
source share
5 answers

There is no "right" way, just like there is no "right" way to place brackets and brackets. This is a matter of style and preference.

It is more important to be consistent.

+9
source

, C int *i, " *i int". . int &i, &i int, int, & .

int& i, i int.

+5

, , type &

+4

, . int & , , Parameter reference-to-int, int & Parameter . , , int & . (.. . http://www.cprogramming.com/tutorial/references.html).

+1

, , .
:

int a | int * b;

(, *), .

, , .

0

All Articles