29.5. Declaring pointers

Here is an example of how a pointer variable of type int is declared:

int* pInt;

or

int *pInt;

The two statements above are equivalent. A pointer [9] called pInt [10] of type int is declared. If a pointer stores an address (which is a numeric value), what does its type (int) mean? The official term for int in this case is the pointer's 'referent type'. The referent type of a pointer tells the compiler what type is expected at the address which it is storing. Here, we know that pInt stores the address of an int.

[9] The term 'pointer' is synonymous with 'pointer variable'. They are used interchangeably in this book and most other literature.

[10] It is customary to name pointers with a small p in front.

It is important ...

Get From Java to C#: A Developer's Guide 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.