dimanche 21 juin 2015

Default_random_engine as a parameter

I am trying to use std::shuffle to create a function that shuffles a word a certain way based on its length. I am not sure on how to use a default_random_engine as a parameter for a function. Does the default random generator need to have a seed before it can be used as a function parameter or can it seed within the function? Sorry if this is confusing, here is a snippet of this function:

string scramble_word(const string & word , default_random_engine& re){
if (word.length() > 3){
    shuffle(word.begin() + 1, word.end() -1, re(0));
    }
if (word.length() <= 3){
    shuffle(word.begin()+1, word.end(), re(0));
    }
return word;

}




Aucun commentaire:

Enregistrer un commentaire