title: Use <random> in a c++ class
body: <p>I want to use the <code>&lt;random&gt;</code> library in my program and I will have classes with different distributions and I want to generate a number at different times in my program. Currently I have the following in my header file</p>
  
  <pre><code>    #include &lt;random&gt;
      #include &lt;time.h&gt;
  
      class enemy {
      private:
          int max_roll;
          typedef std::mt19937 MyRng;
          MyRng rng;
  
      public:
          enemy(int MR){
              max_roll = MR;
              rng.seed(time(NULL));
              std::uniform_int_distribution&lt;int&gt; dice(1, max_roll);
          }
  
          int roll() {
              return dice(rng);
          }
      };
  </code></pre>
  
  <p>I'm getting the issue with 'dice' being undefined even though it's in my constructor there. It will work when I move my distribution definition to the beginning of my roll function, but when I do that, I get the same number every time I call it.  I've tried following the answer on <a href="https://stackoverflow.com/questions/7114043/random-number-generation-in-c11-how-to-generate-how-do-they-work">this</a> question, but I couldn't work it out. </p>