how to make private class member private

psychoticRabbit meagain at meagain.com
Tue Mar 13 02:06:57 UTC 2018


On Tuesday, 13 March 2018 at 01:39:13 UTC, Jonathan M Davis wrote:
>
> private is private to the module, not the class. There is no 
> way in D to restrict the rest of the module from accessing the 
> members of a class. This simplification makes it so that stuff 
> like C++'s friend are unnecessary. If your class in a separate 
> module from main, then main won't be able to access its private 
> members.
>
> - Jonathan M Davis

Mmm.. I don't think I like it.

I feel you should be able to make a member of a class, private, 
regardless of where the class is located. This seems to break the 
concept of class encapsulation.

No. I don't like it at all.



More information about the Digitalmars-d-learn mailing list