C++ random random_device Class
Example
Create a random number with random_device:
random_device rd;
cout << rd();
Definition and Usage
A random_device creates a random number from the computer itself, for example from the hardware.
It is often slow, so it is usually only used once, to give a starting value (a seed) to a faster engine like mt19937.
The random_device class is defined in the <random> header file.
Note: The output is random, so it is different each time you run the program.
Syntax
random_device name;
Parameter Values
None.
Technical Details
| Returns: | Calling name() returns a random unsigned int. |
|---|