Thread overview
private in class - or is it?
Oct 06, 2007
dominik
Oct 06, 2007
Daniel Keep
Oct 06, 2007
BCS
Oct 06, 2007
dominik
Oct 06, 2007
Frank Benoit
Oct 06, 2007
dominik
Oct 06, 2007
Frank Benoit
October 06, 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;
}
----------------------------------- 


October 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.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
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
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
"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
"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
> 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.