Private variables accessible from outside class

Ethan gooberman at gmail.com
Thu Aug 8 15:58:13 UTC 2019


On Thursday, 8 August 2019 at 15:51:45 UTC, Drobet wrote:
> I'm having a weird issue, where after defining my classes 
> variables as private

https://dlang.org/spec/attribute.html

Section 8.4.2 of the spec reads:

Symbols with private visibility can only be accessed from within 
the same module. Private member functions are implicitly final 
and cannot be overridden.

If you were to put that Vector3 class in another module and 
import it, you'll find that private works as you expect.

You'll find this ability very useful when you start using Uniform 
Function Call Syntax in your code.

https://tour.dlang.org/tour/en/gems/uniform-function-call-syntax-ufcs


More information about the Digitalmars-d-learn mailing list