Though with C++11 generators you typically would want to use a distribution instead of the % operator:
1 2 3 4 5 6 7 8 9 10 11
#include <random>
#include <iostream>
usingnamespace std;
int main()
{
random_device gen; // the engine
uniform_int_distribution<int> dist(1,6); // distribution (between 1-6 inclusive .. like a die roll)
cout << dist(gen) << endl; // <- generate a number
}
"If the library implementation employs a random number engine instead of a real-random number generator, the value returned by this function is always zero."