jeudi 3 décembre 2015

LCG class c++ seed generation and operator overloading

I need your help for writting a LCG class in c++. Right now i defined the private member variables and two constructors, one for default values and one for specific ones. But hear comes the problem number one:

The seed for the LCG should be generated within the constructor as well and I have no idea wether I am supposed to just generate a random number with srand() or if there is a standard way of duing it. The ways I tried it did not work.

And my second problem is that i need to " overload the operator()" so that it will return the next number of the LCG i.e.

LCG rnd;

cout << rnd << endl;

which should print a number. I could realy need some help with this one since i ran out of ideas thank you in advance.

PS.: This is the formula that i need to kinda define in the class Xn+1 = (a · Xn + c) mod m




Aucun commentaire:

Enregistrer un commentaire