Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
October 06, 2007 private in class - or is it? | ||||
---|---|---|---|---|
| ||||
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; } ----------------------------------- |
October 06, 2007 Re: private in class - or is it? | ||||
---|---|---|---|---|
| ||||
Posted in reply to dominik | 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.x http://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 |
October 06, 2007 Re: private in class - or is it? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Keep | Reply to Daniel, > 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.x >> > http://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... and 64pt font. > > -- Daniel > > :P > |
October 06, 2007 Re: private in class - or is it? | ||||
---|---|---|---|---|
| ||||
Posted in reply to dominik | 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. |
October 06, 2007 Re: private in class - or is it? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Keep | "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 > > :P make it so man, make it so :) |
October 06, 2007 Re: private in class - or is it? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frank Benoit | "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. |
October 06, 2007 Re: private in class - or is it? | ||||
---|---|---|---|---|
| ||||
Posted in reply to dominik | > 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.
|
Copyright © 1999-2021 by the D Language Foundation