title: Singleton destructor not called?
body: <p>So I've written a simple singleton class. When I create an object the constructor is called, but it's destructor (which frees the object) doesn't seem to be called when it goes out of scope.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class Singleton {
  public:
      static Singleton &amp;getInstance( )
      {
          if (instance == nullptr) {
              cout &lt;&lt; "Creating instance.\n";
              instance = new Singleton();
          }
          return *instance;
      }
      static void destroyInstance( )
      {
          if (instance != nullptr) {
              cout &lt;&lt; "Destroying instance.\n";
              delete instance;
              instance = nullptr;
          }
      }
      ~Singleton( )
      {
          if (instance != nullptr) {
              cout &lt;&lt; "Destroying instance.\n";
              delete instance;
              instance = nullptr;
          }
      }
  private:
      Singleton( ) { }
  
      static Singleton *instance;
  };
  Singleton *Singleton::instance = nullptr;
  
  int main( )
  {
      Singleton &amp;singleton = Singleton::getInstance();
  
      //singleton.destroyInstance();
  
      return 0;
  }
  </code></pre>
  
  <p>With the destructor code the program just outputs this.</p>
  
  <pre><code>Creating instance.
  </code></pre>
  
  <p>If I comment out the destructor and use the <code>destroyInstance()</code> function it outputs this.</p>
  
  <pre><code>Creating instance.
  Destorying instance.
  </code></pre>
  
  <p>Why is it doing this?</p>
  
  <p>EDIT: I'm an idiot. Just overlooked a bunch of things. This question might as well be deleted as it's not really that useful. </p>