12.2 THE & (AND) OPERATOR

The ampersand operator ‘&’ is pronounced as “and” for simplicity. When we apply this to x we write it as &x and pronounce “and x”. We mean address of x by this expression. Naturally, there will be restrictions on what x can be. To have an address, x must reside in memory. Hence, it must be a variable (except for register variable). x can be an array element either. Note x cannot be expression (as it does not have a specific memory location). If our program has following declarations:

int i, a[30];

float x, y[25];

we are allowed to say &i , &a[0], &a[27] ,&x, &y[21] etc. However, we cannot say &(23+4).

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.