programming-examples/c++/Others/Random.h - Header file for random number class.cpp

34 lines
1.0 KiB
C++
Raw Normal View History

2019-11-15 12:59:38 +01:00
Random.h - Header file for random number class
#ifndef RANDOM_H_
#define RANDOM_H_
// Random class
// This code assumes 32-bit ints,
// which are standard on modern compilers.
//
// CONSTRUCTION: with (a) no initializer or (b) an integer
// that specifies the initial state of the generator
//
// ******************PUBLIC OPERATIONS*********************
// Return a random number according to some distribution:
// int randomInt( ) --> Uniform, 1 to 2^31-1
// int random0_1( ) --> Uniform, 0 to 1
// int randomInt( int low, int high ) --> Uniform low..high
class Random
{
public:
explicit Random( int initialValue = 1 );
int randomInt( );
int randomIntWRONG( );
double random0_1( );
int randomInt( int low, int high );
private:
int state;
};
#endif