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

Steven Schveighoffer schveiguy at gmail.com
Fri Oct 26 18:45:06 UTC 2018


On 10/26/18 2:16 PM, 12345swordy wrote:
> Mike Parker told me that this is intentional and not a bug. However 
> according to the spec: "Symbols with private visibility can only be 
> accessed from within the same module. Private member functions are 
> implicitly final and cannot be overridden."
> Why private member variables behave like protected member variables in 
> the same module? Can you explain your thought process when it comes to 
> this design decision Walter Bright? Is there no way to mark the private 
> member variables as "final" in the same module?

There's no such thing as "final" member variables.

private variables and functions are visible ONLY within the module. 
private *functions* are final, meaning derived types cannot override 
them (and they are not virtual).

-Steve


More information about the Digitalmars-d mailing list