Is there a way to choose a random button using nana library?

61 views Asked by At

So i just started using nana c++ library. I made some buttons and i need to find a function or something that choose a random button from those i created. Is there anyway i can do that? Ps: i'm using code::blocks

1

There are 1 answers

0
MSalters On BEST ANSWER

There's no real reason to use an extra library for the random part; the C++ standard library has the functionality already. See <random>; you'd probably want a std::uniform_int_distribution. This assumes you've got your buttons numbered; else just stuff a pointer to each button in a std::vector<Button*>.

One tip: unlike almost all C++ functions, std::uniform_int_distribution will generate numbers up to and including std::uniform_int_distribution::max.