title: Which recursive function will cost less memory?
body: <pre><code>void func(int depth){
      if(depth== 0) return;
      int number(12345);
      cout &lt;&lt; number; //it does something with number
      func(--depth);
  }
  void func2(int depth){
      if(depth== 0) return;
      {
          int number(12345);
          cout &lt;&lt; number; //it does something with number
      }
      func2(--depth);
  }
  void main(){
      func(10); //will this function cost more memory?
      func2(10);//will this function cost less memory?
  }
  </code></pre>
  
  <p>Hi. I have two functions here. Will func2 cost less memory because its number(12345) is encapsulated by "{}" so that by the time func2 calls the next iteration, number(12345) can go outside the scope and disappear?</p>
  
  <p>I believe func will cost more because its number(12345) is not outside of the scope even when it reaches the next iteration?</p>