I found today there two different code segments which show usage of random distribution functions.
First one, a constructor was called, followed by "()", that's familiar to me.
std::uniform_int_distribution<> dis(1, 6);
Second one, an object is constructed thru a "{}", that's confused me.
std::normal_distribution<> d{5,2};
I've test these two examples: first(https://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution) and second(https://en.cppreference.com/w/cpp/numeric/random/normal_distribution), and they works well.
I've not seen syntax like the second example, can some one show me, thx.
Aucun commentaire:
Enregistrer un commentaire