I was wondering is there is a difference when referencing a variable, where the 'reference sign' goes?
such as...
vector<int>& v;
vector<int> &v;
Is there a difference at all, or is it really just preference?
It's totally preference, but I like to keep the & next to the type when I'm declaring a variable or specifying a parameter. That way, when I'm referencing a variable and use &my_variable
, I know just by looking at it that it's a variable reference and has nothing to do with a declaration. I do the same thing with pointers. I declare them int* ptr;
so that way when I see *ptr
I know it's just dereferencing it.
Totally preference, it's the only order that's important.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With