mercredi 5 octobre 2016

random int in c++ using random device and mt19937

I am just starting to learn c++ by programming a game and have been good up until now. I have everything in place for the engine but cannot for the life of me figure out the syntax/reason my random number is not working.

there is only one method calling for a random integer so far in my program and it keeps giving back 'generate' is not a member of random_device.

I have the #include in my class

and here is the code i am trying to use to generate the random integer.

    int Game::randNumb(int min, int max)
{
    std::random_device rd;
    std::mt19937 rn(rd);
    std::uniform_int_distribution<int> dist(min, max);

    return dist(rn);
}




Aucun commentaire:

Enregistrer un commentaire