CHAPTER 8

image

Generating Random Numbers

The need to generate random numbers arises very often. Most games programs, programs that simulate the real world, almost always need the ability to generate random numbers. Testing a complex program usually needs random input at some point to validate that the program works under diverse conditions, and it’s often convenient to generate such input programmatically. Of course, random numbers can be used to generate random choices of objects, so you have the ability to create random selections of anything.

Unless noted otherwise, all the STL templates discussed in this chapter are defined in the random header. ...

Get Using the C++ Standard Template Libraries 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.