title: C++: save variable value for next call of the function
body: <p>Is there a way to initialize a variable in a function and save its value for next call of function?</p>
  
  <p>I'm making application in qt and i have one function connected with a signal. I want an variable in that function to change after the other one reaches its goal. Here is the body of that function:</p>
  
  <pre><code>void objekt::advance(int phase)
  {
  if(!phase) return;
  
  QPointF location = this-&gt;pos();
  if (int(location.x())==200 || int(location.x())==-200)
  {
      smijer=-smijer;
  
  }
  setPos(mapToParent(smijer,0));
  }
  </code></pre>
  
  <p>I defined the smijer variable as static int. But i dont'know how to initialize it only once, when program starts, and how to keep its new value after each call of the function.</p>