how to make private class member private

JN 666total at wp.pl
Tue Mar 13 15:15:14 UTC 2018


On Tuesday, 13 March 2018 at 02:06:57 UTC, psychoticRabbit wrote:
> 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.

Relevant article: 
http://www.drdobbs.com/cpp/how-non-member-functions-improve-encapsu/184401197




More information about the Digitalmars-d-learn mailing list