Broken?

monarch_dodra monarchdodra at gmail.com
Wed Mar 12 06:45:22 PDT 2014


On Wednesday, 12 March 2014 at 13:22:34 UTC, Steven Schveighoffer 
wrote:
> OK, I can see that being useful. You are right, I was thinking 
> C++ private.
>
> -Steve

Even in C++, private virtual a key part of the "non-virtual 
interface" thing.

EG: You define your base class as having only non-virtual public 
functions, and private virtual function. They are private, so the 
derived classes can't *call* them, but they can still override 
them.

The idea is that the base class holds any "non-modifyable" 
behavior, and the virtual functions are only "customizeable 
sub-part behavior".

For example, C++ streams work that way: All the public functions 
are non-virtual. To create your own streams, you are supposed to 
only override a set of low level functions, and then the base 
class takes care of calling them correctly.

In any case, that's how "private virtual" makes sense in C++. I'm 
less fluent with how it works D classes, but last time I read 
TDPL, I seem to remember it was built-in in some way.


More information about the Digitalmars-d mailing list