title: access variables from other function c++
body: <p>I must access variables declared inside other function.</p>
  
  <p>Assume <code>f1()</code></p>
  
  <pre><code>void f1()
  {
    double a;
    int b;
    //some operations
  }
  </code></pre>
  
  <p>and <code>f2()</code></p>
  
  <pre><code>void f2()
  {
    //some operations
    //access a and b from f1()
  }
  </code></pre>
  
  <p>Is it possilbe in c++? How can that be done?</p>
  
  <p>Passing reference to function as shown <a href="https://stackoverflow.com/questions/11783435/how-to-access-variables-defined-and-declared-in-one-function-in-another-function.">here</a> is not suitable answer for my case because this corrupts the order of calling functions. Declaring global variables also denied.</p>