I have tried the output of the following code. But, i don't yet understand what might the value of q represent.
I understand that the *q points to p implying that, printing *q would print the address of p, where as **q would print the value at the address p points to, i.e., x(=5).
#include <iostream>
using namespace std;
int main()
{
int x=5;
int *p,**q;
p=&x;
q=&p;
cout<<q;
return 0;
}
So what does q alone represent? What is that value that is printed when just q is printed?
You say:
However this is not true. Printing
q
would print the address ofp
. After all, you assigned that in doingq = &p;
.Printing
*q
would print the value ofp
, which is the address ofx
.