title: Initialization of struct pointer containing a struct pointer of same type
body: <p>I am trying to understand how the initialization of a pointer to a struct object (which contains a pointer to a struct of the same type) occurs. e.g I have a <code>struct</code>:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>struct node {
      node *next;
    };
  </code></pre>
  
  <p>Suppose I have the starting address of a pool of memory i.e pool is a pointer to the starting location. (For sake of argument lets say the starting memory is <code>1001</code>.)</p>
  
  <pre class="lang-cpp prettyprint-override"><code>char* pool[65536];
  </code></pre>
  
  <p>Now I declare a pointer of type <code>node</code> and assign it the starting memory through <code>reinterpret_cast</code>.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>node* a =reinterpret_cast&lt;node *&gt;(pool);
  </code></pre>
  
  <p>Currently <code>a</code> points to the memory <code>1001</code>. Now I declare another pointer</p>
  
  <pre class="lang-cpp prettyprint-override"><code>node* b;
  b=a;
  </code></pre>
  
  <p>Now what happens is that <code>b</code> points to the same address as <code>a</code> i.e <code>1001</code>. The pointer <code>b-&gt;next</code> points to some random location which is expected but the address of the pointer <code>b-&gt;next</code> is the same as the address to which <code>b</code> is pointing i.e <code>1001</code>. i.e</p>
  
  <pre><code>&amp;b-&gt;next = b
  </code></pre>
  
  <p>I don't understand why the address of <code>b-&gt;next</code> is the same as the one to which pointer <code>b</code> is pointing? According to my understanding <code>b-&gt;next</code> should be located where <code>b</code> is located.</p>
  
  <p>P.S: I have tried to find how this happens but could not find the relevant documentation. If this type of question is already answered in some documentation or another question, please do provide a link.</p>
  
  <p>P.P.S: After discussing this problem further with my colleague, I found out that <code>b</code> is a pointer and not an object. It is pointing to a location (i.e <code>1001</code>) where according to <code>b</code> a node object exists which contains the pointer <code>next</code> and therefore the address of <code>b-&gt;next</code> (<code>&amp;b-&gt;next</code>) is the same as the location to which <code>b</code> is pointing.</p>
  
  <p><img src="https://i.stack.imgur.com/vtGNR.png" alt="enter image description here"></p>