www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Friend class and methods

reply "Maxime Chevalier-Boisvert" <maximechevalierb gmail.com> writes:
Does D have something like the concept of friend classes and 
functions in C++? I'd like to have a function that can access 
private members of two classes at the same time.
Jun 12 2013
next sibling parent "David Nadlinger" <code klickverbot.at> writes:
On Wednesday, 12 June 2013 at 19:01:24 UTC, Maxime 
Chevalier-Boisvert wrote:
 Does D have something like the concept of friend classes and 
 functions in C++? I'd like to have a function that can access 
 private members of two classes at the same time.
No (t really), you have to stick the two classes into the same module. David
Jun 12 2013
prev sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Wednesday, 12 June 2013 at 19:01:24 UTC, Maxime 
Chevalier-Boisvert wrote:
 Does D have something like the concept of friend classes and 
 functions in C++?
The closest is to put both classes and the function in the same module. Things all in the same module can see the private members of each other.
Jun 12 2013
parent reply "Maxime Chevalier-Boisvert" <maximechevalierb gmail.com> writes:
 The closest is to put both classes and the function in the same 
 module. Things all in the same module can see the private 
 members of each other.
Good enough for my needs. Thanks.
Jun 12 2013
parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 06/12/2013 12:12 PM, Maxime Chevalier-Boisvert wrote:
 The closest is to put both classes and the function in the same
 module. Things all in the same module can see the private members of
 each other.
Good enough for my needs. Thanks.
Sometimes 'package' is more suitable than 'private'. Ali
Jun 12 2013