You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we already know that a pointer stores the memory address of other variables. So, when we define a pointer to a pointer, the first pointer is used to store the address of the variables, and the second pointer stores the address of the first pointer. For this very reason, this is known as a Double Pointer or Pointer to Pointer.
What will be the size of a pointer to a pointer in C++?
In the C++ programming language double pointer behave similarly to a normal pointer. So, the size of the variable of the double-pointer and the size of the normal pointer variable is always equal.
// C++ program to implement// pointer to pointer
#include<bits/stdc++.h>usingnamespacestd;// Driver codeintmain()
{
int variable = 169;
// Pointer to store the address// of variableint* pointer1;
// double pointer to store the// address of pointer1int** pointer2;
// Storing address of variable// in pointer1
pointer1 = &variable;
// Storing address of pointer1// in pointer2
pointer2 = &pointer1;
// Displaying the value of variable// with using both single and double// pointers.
cout << "Value of variable :- " <<
variable << "\n";
cout << "Value of variable using single pointer :- " <<
*pointer1 << "\n";
cout << "Value of variable using double pointer :- " <<
**pointer2 << "\n";
return0;
}