Why do private member variables behaved like protected in the same module when creating deriving class?

Patrick Schluter Patrick.Schluter at bbox.fr
Mon Oct 29 07:12:22 UTC 2018


On Monday, 29 October 2018 at 00:36:43 UTC, Danni Coy wrote:
> On Sun, Oct 28, 2018 at 9:30 PM unprotected-entity via 
> Digitalmars-d < digitalmars-d at puremagic.com> wrote:
>
>> [...]
> data into a class and instantiate it in order to have 
> encapsulation.
> In C++ for instance often data is put into a class just to have
> encapsulation, this has a cost in resources as well the 
> complexity of
> program.
> In D any data that there only needs to be one copy of and lasts 
> the
> lifetime of the program belongs in a module rather than a class.
> In practice this tends to mean less classes, and less of the 
> work done
> inside classes.
> D source code can feel inside out compared to C++ source code.

No need for complicated singleton pattern in D.


More information about the Digitalmars-d mailing list