title: Local variables definition in relation to scope, C++
body: <p>When considering a local variable inside of main, e.g.</p>
  <pre><code>#include &lt;iostream&gt;
  void doNothing(int x)
  {
  }
  
  int main()
  {
    int x{0}, y{0};
    doNothing(x);
    
    return 0;
  }
  </code></pre>
  <p>Would both variables (x,y) still be considered in scope when the function doNothing() is entered? I understand that a variables scope extends to where the identifier can be accessed in source code, but from my understanding, y would be inaccessible inside of the function doNothing()</p>
  <p>If it is to be understood that a local variables lifetimes starts when it enter scope and ends when it goes out of scope, would its lifetime then end and be reinstated when returning to main() during runtime?</p>
  <p>I would suppose this is impossible as the variable would have to be redefined and reinstantiated which would mean returning to the top of main(), but then how is y still considered to still be in scope? Is the awaiting function call of doNothing(x) still holding it in scope?</p>
  <p>(I understand this may seem to be a silly question as it clearly must somehow be in scope, I just like to have a clear definition of everything I am working with, perhaps overthinking it a bit too much)</p>
  <p>This question comes from a note provided in a coding tutorial I am currently going through,</p>
  <blockquote>
  <p>Note that local variables have the same definitions for scope and lifetime. For local variables, scope and lifetime are linked -- that is, a variable’s lifetime starts when it enters scope, and ends when it goes out of scope.</p>
  </blockquote>