Using boost::random and getting same sequence of numbers

前端 未结 6 716
佛祖请我去吃肉
佛祖请我去吃肉 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:51

    Only create a single random number generator so it's only seeded once:

    static boost::mt19937 randgen(static_cast(std::time(0)));
    

提交回复
热议问题