This code:
int a = 5;
int& b = a;
b = 7;
cout << a;
prints out 7, and replacing int& b with int &b also prints out 7.
In fact so does int&b and int & b.
I tested this kind of behavior with a simple class as well. In general, does it ever matter whether the ampersand is placed relative to the type and identifier? Thanks.
No, there is absolutely no difference except coding style. I think the main argument about coding style is that this declaration:
declares
aas anint&andbas anint.