Chapter 19. C++11 Randomization Library

The goal of most software is to make things more predictable and reduce risk; life is risky enough as it is. But some computer programs need to introduce randomization rather than eliminate it. Such programs include games and computer simulations.

For many years, programmers have used the C-library rand function to get a random number. This function still works in C++, and I have used it in previous chapters.

But randomization is a subtle and tricky subject. The new C++11 specification provides more reliable, more versatile, and less-biased random-number generation. To explain why the C++11 specification is superior in this area, I first need to discuss general issues in randomization.

19.1. Issues in ...

Get C++ for the Impatient now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.