title: What is the lifetime of a static variable in a C++ function?
body: <p>If a variable is declared as <code>static</code> in a function's scope it is only initialized once and retains its value between function calls. What exactly is its lifetime? When do its constructor and destructor get called?</p>
  
  <pre><code>void foo() 
  { 
      static string plonk = "When will I die?";
  }
  </code></pre>