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

Atila Neves atila.neves at gmail.com
Fri Nov 2 12:45:26 UTC 2018


On Friday, 2 November 2018 at 00:54:43 UTC, Adam D. Ruppe wrote:
> On Thursday, 1 November 2018 at 23:23:55 UTC, 
> unprotected-entity wrote:
>> It's about clean architecture.
>
> If you use interfaces correctly, there will be no private 
> members accessible regardless of privacy and D's module system.
>
> interface I {}
> class B : I {}
>
> void workWithIt(I i) {
>     // nothing in B is accessible without ugly casts!
> }

Yeah, if you're doing OOP and you're not passing interfaces 
around, you're doing it wrong.


More information about the Digitalmars-d mailing list