Help! Random number generate

Is it possible that have a function or class can generate independent random number . And I can use it any time. Thanks.
http://www.cplusplus.com/articles/EywTURfi/

i suppose it will help, havent read it though!!
Have fun with this one.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//random fun with a function

#include <iostream>
#include <ctime>
using namespace std;

void randomfun(int& r, int i) {
	r = rand() %i;
}


int main() {

	srand(time(NULL));

	int a, b, c;

	randomfun(a, 3);
	randomfun(b, 10);
	randomfun(c, 6);

	cout << "a= " << a << endl;
	cout << "b= " << b << endl;
	cout << "c= " << c << endl;

	system("PAUSE");
return 0;
}
using rand() is not exactly independant. There is Mersenne Twister.
Topic archived. No new replies allowed.