Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::random distribution is not working within a custom class
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-07-08 12:46:12


AMDG

Oliver Fochler wrote:
> Some minimal example
>
> -----------------
> random2.h
> -----------------
> <snip>
> class randomNumberGenerator
> {
> <snip>
> private:
> boost::uniform_01<boost::mt19937&, double> * ran_boost;
> };
>
> -----------------
> random2.cpp
> -----------------
>
> <snip>
>
> randomNumberGenerator::randomNumberGenerator( const uint32_t s )
> {
> boost::uniform_01<boost::mt19937&, double> * ran_boost = new
> boost::uniform_01<boost::mt19937&, double>( rng_mt_boost );
> rng_mt_boost.seed( s );
>

You're creating a local variable here, not initializing the
member ran_boost.

> std::cout << ran_boost->operator()() << std::endl;
> }
>

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net