private in class - or is it?
dominik
aha at aha.com
Sat Oct 6 09:16:56 PDT 2007
ok, I'm really having problems with understanding this.. private should be
private, no? I didn't find anything related to this in documentation.
Apparently, private has no meaning - not the way as I see it anyways. Works
both with private keyword preceding variable or private block {}
I'm using 2.005 - but works the same way in 1.x
code:
-----------------------------------
import std.stdio;
class Testor {
private int m_something;
this() {
m_something = 5;
writefln(m_something);
}
~this() {
writefln("Bye now...");
}
void give_me() {
writefln(m_something);
}
void set_me(int x) {
m_something = x;
}
}
void main(char[][] args) {
Testor blabla = new Testor; // writefln from this() == 5
blabla.give_me(); // Works as it should == 5
blabla.m_something = 88; // WTF??
blabla.give_me(); // == 88
blabla.set_me(983); // Works as it should == 983
blabla.give_me(); // == 983
delete blabla;
}
-----------------------------------
More information about the Digitalmars-d-learn
mailing list