Private variables accessible from outside class

Drobet a at b.c
Thu Aug 8 15:51:45 UTC 2019

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 

import std.stdio;

class Vector3
     this(double _x = 0.0, double _y = 0.0, double _z = 0.0)
	x = _x;
         y = _y;
         z = _z;

         double x, y, z;

int main()
     Vector3 vec = new Vector3(5, 5, 5);
     vec.x = 10;


     return 0;

My question is if this is intended behavior, and if yes, why?

More information about the Digitalmars-d-learn mailing list