I want to generateQuest
generate random numbers between type of variable range. The problem is, it generates always the same number. I do not know why.
Main
#include <iostream>
#include "util.h"
int main()
{
std::cout << generateQuest<short>() << std::endl;
std::cout << generateQuest<short>() << std::endl;
}
Implementation of the method:
#ifndef UTIL_H
#define UTIL_H
#include <random>
using namespace std;
template<class Typ>
Typ generateQuest()
{
default_random_engine generator {std::random_device{}()};
uniform_int_distribution<Typ> distribution(numeric_limits<Typ>::min(),numeric_limits<Typ>::max());
return distribution(generator);
}
#endif
The output is: -24760 twice:
Aucun commentaire:
Enregistrer un commentaire