-3

Possible Duplicate:
What's the meaning of * and & when applied to variable names?

How to use & operator? herein i have an example:

Const  type& var
Const type & var
Const type &var

what does it mean? Bests

Community
  • 1
  • 1
  • I am not sure what you guys have smoked, but this is most certainly a totally real question. It's a dupe of http://stackoverflow.com/q/3350626/140719, though. – sbi Nov 12 '11 at 16:18
  • @sbi: I second that,I am against Questions being closed as not a real Q just because they are pretty obvious to regular users of C++. For a beginner(inquisitive one) this is indeed an real question. probably, It is a duplicate(as Sbi found out) but neither did any of the members who closed it,added a comment with the reason of closing it. – Alok Save Nov 12 '11 at 16:23
  • @Als: I flagged for a mod to fix that. I dunno whether any mod is around today, though. – sbi Nov 12 '11 at 16:24
  • You are confusing the meaning of `&`: in the present context, it is a modifier that designates a *reference* type. That's completely unrelated to many other meanings it can have (such as the "address-of" operator, the "bitwise-and" operator, or as part of the "logical-and" operator, or as a "user-defined `&`-operator"). – Kerrek SB Nov 12 '11 at 16:33

1 Answers1

3

All of them mean the same. It makes no difference to the compiler which one you use.
For the compiler,
All three of those statements create a reference to a constant type.

It is a mere matter of style where to place the &. Use the style which your coding style/guidelines suggest you to use.

Alok Save
  • 202,538
  • 53
  • 430
  • 533