title: Scope of an object created in an if-condition in C++
body: <p>In the following example</p>
  
  <pre><code>void fun() {
      if(int i=SOME_VALUE) {
          // ...
      } else {
          // ...
      }
  }
  </code></pre>
  
  <p>What is the scope of i? Can we use it inside the if-block? Can we use it inside the else-block?</p>
  
  <p><em>Edit:</em> </p>
  
  <p>As a follow-up, in this modified example</p>
  
  <pre><code>void fun() {
      if(int i=SOME_VALUE) {
          // ...
      } else if(int j=SOME_OTHER_VALUE){
          // ...
      } else {
          // ...
      }
  }
  </code></pre>
  
  <p>Can we access both i and j in the else clause?</p>