title: Static random number generator losing seed for global variable
body: <p>I wanted to make an easy way to grab a random number, however, gen, the random number generator seems to lose its seed across functions. If you run this example multiple times, you will see that the first random number generated is random each run, while the second is not. What is the cause of this?</p>
  
  <p>main.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Random.hpp"
  class Global
  {
  public:
      Global()
      {
          Random::seed();
          std::cout &lt;&lt; "\n" &lt;&lt; Random::getRandom(-10, 10);//random
      }
      void Global::doStuff()
      {
          std::cout &lt;&lt; "\n" &lt;&lt; Random::getRandom(-10, 10);//not random
      }
  };
  Global globalInstance;
  
  int main()
  {
      globalInstance.doStuff();
      return 0;
  }
  </code></pre>
  
  <p>Random.hpp</p>
  
  <pre><code>#pragma once
  #include &lt;random&gt;
  class Random
  {
  public:
  
      static void seed();
      static int getRandom(int minInclusive, int maxInclusive);
  
  private:
      static std::default_random_engine gen;
      static std::uniform_int_distribution&lt;int&gt; ints;
  
  };
  </code></pre>
  
  <p>Random.cpp</p>
  
  <pre><code>#include "Random.hpp"
  #include &lt;time.h&gt;
  std::default_random_engine Random::gen;
  std::uniform_int_distribution&lt;int&gt; Random::ints;
  void Random::seed()
  {
      gen.seed(static_cast&lt;unsigned int&gt;(time(NULL)));
  }
  int Random::getRandom(int minInclusive, int maxInclusive)
  {
      std::uniform_int_distribution&lt;int&gt;::param_type range(minInclusive, maxInclusive);
      ints.param(range);
      return ints(gen);
  }
  </code></pre>