int helper( mt19937& generator ){
do stuff;
return 0;
}
#include "helper.h"
// helper function defined in separate source file and included in header
mt19937 generator(time(NULL));
int main( ) {
help(generator);
}
Is it correct to create and seed the mt19937 random number generator, then pass it by reference to a function for use?
I am doing this because I know I am suppose to only seed mt19937 once. But I have a lot of helper functions in separate source files that need to use a random number generator. E.g. with the shuffle function.
Aucun commentaire:
Enregistrer un commentaire