Static members confuse me sometimes. I understand how to initialize a simple built in type such as int
with something along the lines of int myClass::statVar
Just write a function which returns a reference to a properly randomized RandomGenerator and turn itsGenerator into a reference to a generator:
class myClass
{
public:
// Some methods...
protected:
// make this a reference to the real generator
static RandomGenerator& itsGenerator;
public:
static RandomGenerator& make_a_generator()
{
RandomGenerator *g=0;
g=new RandomGenerator();
g->Randomize();
return *g;
}
}
RandomGenerator& myClass::itsGenerator=myClass::make_a_generator();