Wednesday, June 29, 2011

Address Opertor(&)

Address operator also known as reference operator '&'. Address operator '&' returns the address of a variable when place before it. The address that locates a variable within memory is what we call a reference to that variable. Address operator '&' can  be read as "address of". For example:
                                                  &a means "address of a"
                                                 &salary means "address of salary"
int a=45;

suppose at runtime a is placed in the memmory address 1886.


b=a;
this will assign the value of a to the variable b.
c=&a;
 this will assign the address of variable a to the variable c. The variable that store the reference of another variable(like c) is what we call a pointer.

No comments:

Post a Comment