need help explaining this

hi. I'm currently working on an Internet clock which connects to NTP server and reads the time. I'm using adafruits code as reference but I have some problems understanding the code. here is the first part:

unsigned long sendNTPpacket(IPAddress& address)

why is there a "&" at the end of "IPAddress"? is this always necessary?
my second question is about a line of the code which sets the time zone offset in relation to UTC:
int tzOffset = -4;                  // Time zone offset
what if my time zone offset is like say UTC+5:30?

Thats the syntax for pass-by-reference.

For finer tz granularity you could rework tzOffset to be in minutes, and change all the uses of it.

MarkT:
Thats the syntax for pass-by-reference.

now what's that???

leon_ronin:
now what's that???

I think it is well explained by the "Arguments passed by value and by reference" and "Efficiency considerations and const references" sections of this page:
http://www.cplusplus.com/doc/tutorial/functions/
In this case, it is done for the sake of efficiency.

Note this code does not follow best practices. They should have made the address parameter const. If there was an error in the code that inadvertently modified the value of address, this could result in a very confusing bug with the current code. But with const you would get a helpful compiler error message and be able to immediately spot the problem. In fact you should make every variable const if you don't intend to change the value, it's just that this is even more important in the case of pass by reference.

leon_ronin:

unsigned long sendNTPpacket(IPAddress& address)

why is there a "&" at the end of "IPAddress"? is this always necessary?

I think I am correct in saying that & is between the IPAddress and address - in other words these versions would have exact same effect

unsigned long sendNTPpacket(IPAddress & address)
unsigned long sendNTPpacket(IPAddress &address)
unsigned long sendNTPpacket(IPAddress&address)

...R

Yes, & is a token, identifiers are tokens, whitespace is optional between tokens unless it would
be ambiguous w.r.t. a longer token. Thus one needs a space before two else it
would be a single token onetwo, += is always a single token, +  = is two tokens
and I believe is is syntactically impossible in a valid program.

So you are right all three are exactly the same to the compiler.

Passing by reference is a choice you make. Its usually preferable to passing an explicit pointer,
which can be used to achieve the same effect. Passing by value and pass by reference are worth
getting straight in your head, side effects on something passed by reference are visible outside the function.