Hi!
In addition to Steven's remark: May be it relates to minimal example, but why do you need a member pointer here? And why don't you delete it?
I think that would be a better approach:
-----------------
random2.h
-----------------
#ifndef RANDOM_NG_H
#define RANDOM_NG_H
#include <stdint.h>
#include <boost/random.hpp>
class randomNumberGenerator
{
public:
randomNumberGenerator( const uint32_t s );
double operator()() { return ran_boost(); }
private:
boost::mt19937 rng_mt_boost_;
boost::uniform_01<boost::mt19937&, double> ran_boost_;
};
extern randomNumberGenerator ran2;
#endif
-----------------
random2.cpp
-----------------
#include <iostream>
#include <boost/random.hpp>
#include "random2.h"
randomNumberGenerator ran2;
randomNumberGenerator::randomNumberGenerator( const uint32_t s )
: rng_mt_boost_()
, ran_boost_(rng_mt_boost_)
{
rng_mt_boost_.seed( s );
std::cout << ran_boost_() << std::endl;
}
Regards,
Ovanes
AMDG
Oliver Fochler wrote:
You're creating a local variable here, not initializing the
member ran_boost.In Christ,
Steven Watanabe