As we know by now that a pointer stores the address of the pointed variable. But it is not the only use, pointer also stores the address of another pointer forming a chain like structure.
When we defined the pointer to a pointer, it means the first pointer contains the address of the second pointer and the second pointer contains the address of an actual variable.
We can declare the pointer to pointer variable by simply adding an additional asterisk * before the pointer name. example:
C++ Program for Pointer to Pointer
using namespace std;
int main ()
int num = 100;
//assigning address to pointer
ptr1 = #
ptr2 = &ptr1;
// value present in each varibles
cout << "Value stored by var :" << num << endl;
cout << "Value stored byt *ptr1 :" << *ptr1 << endl;
cout << "Value stored by **ptr2 :" << **ptr2 << endl;
Output: After execution, the following output will be displayed.
Value stored by var :100
Value stored byt *ptr1 :100
Value stored by **ptr2 :100