+4  A: 

Make rng() const function: const gsl_rng* rng() const {.

wilx
wilx is right. const gsl_rng* rng(){} only says that the returned pointer is const but you have to state that the function doesn't modify the object, too. This is the second const before the {}
fschmitt
There's more to it than this.
John Dibling
you guys are great!
Jerry Gagelman
+3  A: 

Change this function to:

const gsl_rng* rng() const {
    return r_;
}   
ybungalobill
+2  A: 

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_;
    }   
John Dibling
Thanks for the detailed answer. I've always wondered what those <code>const</code> between the declaration and definition means. This is really helpful.
Jerry Gagelman
@Jerry: You're welcome. Just by way of brief explanation, when you declare a member function `const`, you are telling the compiler to interpret the `this` pointer as `const`, so you won't be able to call any non-`const` member functions or change any non-`mutable` member variables.
John Dibling