Using boost::random and getting same sequence of numbers

前端 未结 6 682
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-19 19:04

I have the following code:

Class B {

void generator()
{
    // creating random number generator
    boost::mt19937 randgen(static_cast(s         


        
6条回答
  •  时光说笑
    2020-12-19 19:59

    If you do not want to use only one generator you could create one generator with seed(time(0)) and then use that generator as seed into the other generators.

    time(0) has the resolution of 1 second. Using it multiple times as seed within a short time span will create the same generator.

提交回复
热议问题