Re: Private variables accessible from outside class

2019-08-08 Thread ag0aep6g via Digitalmars-d-learn
On 08.08.19 18:03, Drobet wrote: Then why does it in the tour say that it can only be "seen by Integer"? https://tour.dlang.org/tour/en/basics/classes That's an error in the tour.

Re: Private variables accessible from outside class

2019-08-08 Thread Drobet via Digitalmars-d-learn
On Thursday, 8 August 2019 at 15:53:13 UTC, Zoadian wrote: private means module private in D. see: https://dlang.org/spec/attribute.html#visibility_attributes Then why does it in the tour say that it can only be "seen by Integer"? https://tour.dlang.org/tour/en/basics/classes

Re: Private variables accessible from outside class

2019-08-08 Thread Paul Backus via Digitalmars-d-learn
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, they can still be modified and looked at from the outside. That leads to this code compiling with no issues. [...] My question is if this is intended

Re: Private variables accessible from outside class

2019-08-08 Thread Ethan via Digitalmars-d-learn
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.

Re: Private variables accessible from outside class

2019-08-08 Thread matheus via Digitalmars-d-learn
On Thursday, 8 August 2019 at 15:51:45 UTC, Drobet wrote: ... My question is if this is intended behavior, and if yes, why? This is true if the class is inside the same module: "Private means that only members of the enclosing class can access the member, or members and functions in the same

Private variables accessible from outside class

2019-08-08 Thread Drobet via Digitalmars-d-learn
I'm having a weird issue, where after defining my classes variables as private, they can still be modified and looked at from the outside. That leads to this code compiling with no issues. import std.stdio; class Vector3 { this(double _x = 0.0, double _y = 0.0, double _z = 0.0) {

Re: Private variables accessible from outside class

2019-08-08 Thread Zoadian via Digitalmars-d-learn
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, they can still be modified and looked at from the outside. That leads to this code compiling with no issues. import std.stdio; class Vector3 {