title: C++ am I correct about where each variable is stored?
body: <p>Given this code:</p>
  
  <pre><code>void myFunction (int * a) {
      *a = 10;
  }
  
  int main () {
      int *b = new int;
      *b = 20;
      myFunction(b);
  }
  </code></pre>
  
  <p>Am I right to think that both <strong>a</strong> and literal value <strong>10</strong> are stored in the <strong>stack</strong> (with <strong>a</strong> holding the memory address of the literal value 10)?</p>
  
  <p>And also, is correct to say that <strong>b</strong> is stored in the stack while the value <strong>20</strong> is stored in the heap?</p>
  
  <p>Thanks!</p>