title: Why is the value of i == 0 in this C++ code?
body: <p>I am confused about the following code:           </p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int i = 1;
  int main()
  {
      int i = i;
      std::cout &lt;&lt; "i: " &lt;&lt; i &lt;&lt; "\n";
      return 0;
  }
  </code></pre>
  
  <p><strong>Output:</strong>          </p>
  
  <pre><code>i: 0
  </code></pre>
  
  <p>I had expected running the above code would print <code>1</code>. Can someone please explain the reason for this strange behavior?</p>