www.digitalmars.com         C & C++   DMDScript  

D - "friend"-replacement?

reply Norbert Nemec <Norbert.Nemec gmx.de> writes:
Hi there,

obviously, "friend" declarations from C++ do not exist in D. Is there any
alternative way to implement a group of classes that interdepend on each
other's internals without exposing these to the outside world?

Thanks,
Nobbi
Apr 25 2004
parent reply J Anderson <REMOVEanderson badmama.com.au> writes:
Norbert Nemec wrote:

Hi there,

obviously, "friend" declarations from C++ do not exist in D. Is there any
alternative way to implement a group of classes that interdepend on each
other's internals without exposing these to the outside world?
  

-- -Anderson: http://badmama.com.au/~anderson/
Apr 25 2004
parent reply Norbert Nemec <Norbert.Nemec gmx.de> writes:
J Anderson wrote:
 Norbert Nemec wrote:
obviously, "friend" declarations from C++ do not exist in D. Is there any
alternative way to implement a group of classes that interdepend on each
other's internals without exposing these to the outside world?
  


??? As far as I understand, you can have classes and functions private to a module or class members private to the class, but how do you make class members private to the module?
Apr 25 2004
next sibling parent "Ivan Senji" <ivan.senji public.srce.hr> writes:
"Norbert Nemec" <Norbert.Nemec gmx.de> wrote in message
news:c6g2ft$16na$1 digitaldaemon.com...
 J Anderson wrote:
 Norbert Nemec wrote:
obviously, "friend" declarations from C++ do not exist in D. Is there



alternative way to implement a group of classes that interdepend on each
other's internals without exposing these to the outside world?


??? As far as I understand, you can have classes and functions private to a module or class members private to the class, but how do you make class members private to the module?

This is not possible. One module should contain only classes that are friends.
Apr 25 2004
prev sibling next sibling parent reply "Scott Egan" <scotte tpg.com.aux> writes:
From memory private in a class is only private to the module.

See: http://www.digitalmars.com/d/attribute.html

"Norbert Nemec" <Norbert.Nemec gmx.de> wrote in message
news:c6g2ft$16na$1 digitaldaemon.com...
 J Anderson wrote:
 Norbert Nemec wrote:
obviously, "friend" declarations from C++ do not exist in D. Is there



alternative way to implement a group of classes that interdepend on each
other's internals without exposing these to the outside world?


??? As far as I understand, you can have classes and functions private to a module or class members private to the class, but how do you make class members private to the module?

Apr 25 2004
parent Norbert Nemec <Norbert.Nemec gmx.de> writes:
Scott Egan wrote:
 From memory private in a class is only private to the module.

OK, the documentation can be understood like that, but it is not very concise in this point.
Apr 25 2004
prev sibling parent J Anderson <REMOVEanderson badmama.com.au> writes:
Norbert Nemec wrote:

As far as I understand, you can have classes and functions private to a
module or class members private to the class, but how do you make class
members private to the module?
  

I'm not quite sure what you asking. When you use private in a module (whether it's within a class or not) it behaves on the module level. ie class A { private int x; } void main() { A a = new A; a.x = 10; //No error (if it was a different module there would be) } -- -Anderson: http://badmama.com.au/~anderson/
Apr 25 2004