Boost logo

Boost Users :

Subject: Re: [Boost-users] [Random] Passing an arbitrary uniform random number generator to a function
From: Marco Guazzone (marco.guazzone_at_[hidden])
Date: 2010-04-29 08:46:42


On Thu, Apr 29, 2010 at 11:34 AM, Joseph Gauterin
<joseph.gauterin_at_[hidden]> wrote:
>>Making it private don't see how it could work
> C++'s private does not prevent ovrerriding (unlike some other languages)
>

Thank you.
I admit this were unknown to me. I though that derived classes could
override public/protected function only.

>>Why should the virtual function be private?
> The desired interface is a function that takes any type the implements
> the random double generator 'concept'. Template functions cannot be
> virtual. That leads to a private virtual function (which can be
> overridden in derived classes, but not called) and a public template
> function that calls the private virtual function after translating the
> argument into a useable form.
>
> More generally, Herb Sutter's recommendation to "prefer to make base
> class virtual functions private"
> (http://www.gotw.ca/publications/mill18.htm) is sound advice.

Got it!

Thank you very much for pointing this article out.

Cheers,

-- Marco


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