Make rng() const function: const gsl_rng* rng() const {.
wilx
2010-09-29 20:49:21
Change this function to:
const gsl_rng* rng() const {
return r_;
}
Two problems. First, you are calling a non-const member function through a const object reference. Can't do that. You can make GSLRand::rnd() a const member function:
const gsl_rng* rng() const {
...but then you have a second problem: gsl_rng() returns a const gsl_rng*, but you're trying to assign this to a non-const member variable. Can't do that, either.
Fork in the road. Either you always call const member functions on through the r_ pointer, or you sometimes call non-const member functions through it.
If you always call const member functions, then make the member variable point to a const gsl_rng:
const class gsl_rng* r_; // see links below
Otherwise, make your rng() function return a non-const pointer, while keeping the method itself const:
gsl_rng* rng() const {
return r_;
}