C++ Pointers
The pointer in C++ language is a variable, it is also known as a locator or indicator that points to an address of a value.
or
A pointer variable stores an address of a memory location
The pointers are one of C++’s most useful and strongest features. The correct understanding and use of pointers is critical to successful programming in C++. The reasons that support this are:
1. Pointers provide the means through which the memory location of a variable can be directly accessed and hence can be manipulated in the way as required.
2. Pointers support C++’s dynamic memory allocation routines.
3. Pointer reduces the code and improves the performance, it is used with arrays, structures and functions.
4. Pointers can improve the efficiency of certain routines.
5. We can return multiple values from a function using a pointer.
6. It makes you able to access any memory location in the computer’s memory.
Pointers
Def: A pointer variable is a variable which can store address of another variable of its own type.
Integer pointer variable
Def: An integer pointer variable is a pointer variable which can store address of another variable of type integer.
Float pointer variable
Def: A float pointer variable is a pointer variable which can store address of another variable of type float.
While dealing with pointers we use two special operators
Symbol | Name | Description |
& (ampersand sign) | address of operator/reference operator | Determine the address of a variable. |
∗ (asterisk sign) | value at operator / de reference operator | Access the value of an address. |