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:25:05 UTC 2018
On Friday, 26 October 2018 at 20:55:00 UTC, Jonathan M Davis
wrote:
> On Friday, October 26, 2018 1:55:08 PM MDT 12345swordy via
> Digitalmars-d wrote:
>> On Friday, 26 October 2018 at 19:45:48 UTC, David Gileadi
>> wrote:
>> > [...]
>>
>> If it deliberate, then it needs to be documented.
>
> What are you asking for exactly? The documentation documents
> exactly what the behavior is:
>
> https://dlang.org/spec/attribute.html#visibility_attributes
>
> "2. Symbols with private visibility can only be accessed from
> within the same module. Private member functions are implicitly
> final and cannot be overridden."
>
> Are you looking for the documentation to explain why there is a
> "loophole" to private that allows other symbols within a module
> to access private members of a class of struct?
No I am asking why class B inherent the private variables of
class A that is marked private, when we have the protected
keyword.
I don't know how else I can I make this any clearer.
More information about the Digitalmars-d
mailing list