Syntax
data-type *pointer-name;
Here, ‘pointer-name’ is the name of the pointer variable and ‘data-type’ is any valid C++ data
type. The asterisk operator or star operator (*) means “pointer to”. In C, we can write:
int *ptr;
But in C++ we can also write:
int* ptr;
Note here that both will work, as spaces are optional.
Also note here that the result of the
pointer operator (*) does the reverse of the operator &. The pointer operator (*) returns the
value of the variable stored at the address following it.
So to access the value stored at an address,
we will use the pointer operator.
Do'stlaringiz bilan baham: