Declaration of Pointers in C++

Pointer variables, like all other variables, must be declared before they may be used in a C++ program. The interpretation of a pointer declaration differs, however, from the interpretation of other variable declarations. When a pointer variable is declared, the variable name must be preceded by an asterisk (*). This identifies the fact that the variable is a pointer. The data type that appears in the declaration refers to the object of the pointer, i.e., the data item that is stored in the address represented by the pointer, rather than the pointer itself. This, the pointer declaration may be written in general terms as: data-type *ptvar; where, ptvar is the name of the pointer variable, and data-type refers to the datatype of the pointer’s object. Remember that an * (asterisk) must precede ptvar.