Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
April 25, 2004 "friend"-replacement? | ||||
---|---|---|---|---|
| ||||
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 |
April 25, 2004 Re: "friend"-replacement? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Norbert Nemec | 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? > > Modules. -- -Anderson: http://badmama.com.au/~anderson/ |
April 25, 2004 Re: "friend"-replacement? | ||||
---|---|---|---|---|
| ||||
Posted in reply to J Anderson | 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?
>>
> Modules.
???
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?
|
April 25, 2004 Re: "friend"-replacement? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Norbert Nemec | "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 any > >>alternative way to implement a group of classes that interdepend on each other's internals without exposing these to the outside world? > >> > > Modules. > > ??? > > 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. |
April 25, 2004 Re: "friend"-replacement? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Norbert Nemec | 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 any > >>alternative way to implement a group of classes that interdepend on each other's internals without exposing these to the outside world? > >> > > Modules. > > ??? > > 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? |
April 25, 2004 Re: "friend"-replacement? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Norbert Nemec | 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/ |
April 25, 2004 Re: "friend"-replacement? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Scott Egan | 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.
|
Copyright © 1999-2021 by the D Language Foundation