C++ Pointer Operators
Prerequisite: Pointers in C++
A pointer variable is a variable that stores the address of another variable or in other a pointer variable points to the variable whose address is stored inside it.
There are mainly two types of Pointer operators mainly used:
- Address of operator (&)
- The indirection operator/Dereference operator (*)
1. Address-of operator (&)
The Address-of operator (&) is a unary operator that returns the memory address of its operand which means it stores the address of the variable, which depicts that we are only storing the address not the numerical value of the operand. It is spelled as the address of the variable.
gfg = &x; // the variable gfg stores the address of the variable x.
The address of the variable x is :- 0x7fff412f512c
2. The indirection operator/Dereference operator (*)
The indirection/ dereference operator is a unary operator that returns the value of the variable present at the given address. It is completely opposite to the address-of operator. It is spelled as a value pointed at the address.
The value stored at the variable price is Rs : 3899