On Saturday, 19 January 2013 at 00:04:24 UTC, Andrey wrote:
So how am I supposed to hide the variable inside the struct or
class?
Generally the D answer here is to put them in separate files. The
module (file) is the main D encapsulation unit rather than the
class/struct.
It isn't the same as C++ but I find it works pretty well - you
often do one file per class anyway, and files are a natural unit
for encapsulating too.
I'm sure "friend" explodes the basics of OOP encapsulation
mechanics.
http://www.parashift.com/c++-faq/friends-and-encap.html
If you have helper structures it can be useful to get at the
private parts anyway, for example an iteration range.