title: How to make a roll_die() function with an optional random seed parameter
body: <p>New to c++. I'd like to make a function like <code>roll_die(unsigned int seed = ???)</code> where, by default the function uses <code>srand(time(NULL))</code> to seed the RNG before returning a value, but also allows the user to specify a seed. Here's what I have that works</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;ctime&gt;
  
  int roll_die(unsigned int seed = 0){
      // Returns a random integer between 1 and 6
      // time(NULL) is the number of seconds since 00:00 hours, Jan 1, 1970 UTC
  
      // Logic
      srand(seed);
      int randnum = rand();
  
      // Print what's going on
      std::cout &lt;&lt; "The random seed is: " &lt;&lt; seed &lt;&lt; std::endl;
      std::cout &lt;&lt; "The max random number is: " &lt;&lt; RAND_MAX &lt;&lt; std::endl;
      std::cout &lt;&lt; "The randomly chosen number is: " &lt;&lt; randnum &lt;&lt;std::endl;
  
      // Return the result
      int result = randnum % 6 + 1;
      return result;
  }
  </code></pre>
  
  <p>This is nice, but it doesn't default to a <em>random</em> seed. If I try doing something like <code>int roll_die(unsigned int seed = time(NULL)){...}</code> I get the warning </p>
  
  <pre><code>Unable to parse C++ default value 'time(NULL)' for argument seed of function roll_die
  </code></pre>
  
  <p>I assume because <code>time(NULL)</code> does not return an int.</p>
  
  <p>What is the proper way to do this?</p>