Module-level accessibility

Steven Schveighoffer schveiguy at yahoo.com
Wed Oct 6 04:04:24 PDT 2010


On Tue, 05 Oct 2010 20:27:58 -0400, Jonathan M Davis <jmdavisProg at gmx.com>  
wrote:

> Well, I don't see why it wouldn't be possible for the compiler to  
> enforce that
> overridden private methods can't be called by anyone but the base class.  
> That
> being the case, then allowing for private virtual functions is most  
> definitely
> useful. However, if it really isn't possible to restrict it so that  
> derived
> classes can't call the private methods that they've overridden, then I  
> do agree
> that we might as well just stick to using protected and make private  
> functions
> unoverridable. But if we _can_ make it so that derived classes can't call
> overridden private methods, I think that that would be valuable and  
> desirable.

See my earlier post -- if you control the implementation, the compiler  
cannot prevent you from calling it.  Even if it tries...

http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=118350

So you gain nothing, but annoyance (*grumble* now I have to split my  
implementation from the virtual function just to be able to call it?).

-Steve


More information about the Digitalmars-d mailing list