Why do private member variables behaved like protected in the same module when creating deriving class?
12345swordy
alexanderheistermann at gmail.com
Fri Oct 26 21:42:37 UTC 2018
On Friday, 26 October 2018 at 21:40:10 UTC, Laurent Tréguier
wrote:
> On Friday, 26 October 2018 at 21:16:54 UTC, 12345swordy wrote:
>> It's a problem as we have the protected keyword already! There
>> is no reason for private to act it's protected in the same
>> module!
>> If you want child to inherent your private member variables
>> then used protected.
>> Otherwise private should mean that belongs to class A and only
>> to class A. If you wanted your child class to inherent private
>> member variables only in a module then we need a new access
>> attribute to avoid unwanted pitfuls.
>
> `protected` isn't the same. `protected` will allow derived
> classes to access a member, even if they are not in the same
> module. `private` can only be accessed within a single module.
...Did you read the other post that I made before you made that
reply?
I swear I am repeating myself ad nauseam.
More information about the Digitalmars-d
mailing list