Possible Duplicate:
What makes more sense – char* string or char *string?
Sorry if this is a silly question, I am new to these things 🙂
I am working on a C++ code base which uses the following reference conventions:
- const Name &var
- const Name& var
As far as I’m aware, they mean the same thing.
Which of these is either of these preferred, or mandated?
I don’t like the ambiguity of having to choose one or the other.
The closest I have found to this answer is on http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Reference_Arguments , which uses the &var layout.
From the language or compiler perspective both are exactly same. For a group project, you have to use a group style. For personal project, you are free to make any choice.
Though it is hard, but on topics like these, I always try to remember Rule# 0 from C++ Coding Standards: 101 Rules, Guidelines, Best Practices:
If I have flexibility to choose, then personally, I always having prefer having spaces on either side of ‘*’, ‘&’, ‘=’ etc. and so I write it as
(Also, I never declare two variables in one line.)