Boost logo

Boost Users :

Subject: Re: [Boost-users] [Random] Passing an arbitrary uniform random number generator to a function
From: Joseph Gauterin (joseph.gauterin_at_[hidden])
Date: 2010-04-29 05:34:07


>Making it private don't see how it could work
C++'s private does not prevent ovrerriding (unlike some other languages)

>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.


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