digitalmars.D.learn - private in class - or is it?
- dominik (34/34) Oct 06 2007 ok, I'm really having problems with understanding this.. private should ...
- Daniel Keep (8/14) Oct 06 2007 http://www.digitalmars.com/d/attribute.html
- Frank Benoit (5/5) Oct 06 2007 http://www.digitalmars.com/d/attribute.html#ProtectionAttribute
- dominik (5/10) Oct 06 2007 I guess that's made for modularization - easing in between classes in sa...
- Frank Benoit (2/5) Oct 06 2007 From the thread "Class declaration" Bill said:
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; } -----------------------------------
Oct 06 2007
dominik wrote: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.xhttp://www.digitalmars.com/d/attribute.html "Private means that only members of the enclosing class can access the member, or ***members and functions in the same module as the enclosing class***." I think we need to make that part bold, bright red and flashing... -- Daniel :P
Oct 06 2007
Reply to Daniel,dominik wrote:and 64pt font.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.xhttp://www.digitalmars.com/d/attribute.html "Private means that only members of the enclosing class can access the member, or ***members and functions in the same module as the enclosing class***." I think we need to make that part bold, bright red and flashing...-- Daniel :P
Oct 06 2007
"Daniel Keep" <daniel.keep.lists gmail.com> wrote in message news:fe8d2c$ul3$1 digitalmars.com...I think we need to make that part bold, bright red and flashing... -- Daniel :Pmake it so man, make it so :)
Oct 06 2007
http://www.digitalmars.com/d/attribute.html#ProtectionAttribute cite: Private means that only members of the enclosing class can access the member, or members and functions in the same module as the enclosing class.
Oct 06 2007
"Frank Benoit" <keinfarbton googlemail.com> wrote in message news:fe8dbi$uqf$1 digitalmars.com...http://www.digitalmars.com/d/attribute.html#ProtectionAttribute cite: Private means that only members of the enclosing class can access the member, or members and functions in the same module as the enclosing class.I guess that's made for modularization - easing in between classes in same module, makes sense now. I don't have enough experience to tell if that is good or bad though. Thank you.
Oct 06 2007
I guess that's made for modularization - easing in between classes in same module, makes sense now. I don't have enough experience to tell if that is good or bad though. Thank you.From the thread "Class declaration" Bill said: D doesn't have C++'s "friend" so that's sort of D's substitute.
Oct 06 2007