Welcome to Web-News
A Web-based News Reader
Subject Re: This is not just a question.
From Nick Sabalausky <a@a.a>
Date Wed, 12 Nov 2008 05:40:21 -0500
Newsgroups digitalmars.D

"Yonggang Luo" <yonggangluo@hotmail.com> wrote in message
news:gfdkcs$1all$1@digitalmars.com...
> But the  fact is "private import Base";
> from this clue , we can't access Base Class.
> So it's confusing.
>

"private import" works the same as "private class" and "private foo()". It
means "This module can access it, but nothing else can."

----------------------------------------
module ModuleA;
void fooA()
{
}
//end of file
----------------------------------------
module ModuleB;
void fooB()
{
}
//end of file
----------------------------------------
module ModuleLibrary;

// ModuleLibrary can access all of these
// Anything that imports ModuleLibrary can access all of these
import ModuleA;
class ClassA {}
FunctionA() {}
int VariableA;

// ModuleLibrary can access all of these
// Anything that imports ModuleLibrary can NOT access any of these
private import ModuleB;
private class ClassB {}
private FunctionB() {}
private int VariableB;

//end of file
----------------------------------------
module ModuleMain;
import ModuleLibrary;

//All ok:
fooA();
auto cA = new ClassA();
FunctionA();
VariableA = 1;

//All error:
fooB();
auto cB = new ClassB();
FunctionB();
VariableB = 1;

//end of file
----------------------------------------

So you see, "private import" works just like "private class", "private
Function()" and "private int".



Recent messages in this thread
 
-# A question about the relation between different module. Yonggang Luo 11-Nov-2008 10:53 am
.-# A updated version. Yonggang Luo 11-Nov-2008 10:56 am
.||# Re: A updated version. ore-sama 11-Nov-2008 11:11 am
.|-# Re: A updated version. Jarrett Billingsley 11-Nov-2008 12:03 pm
.|.-# This is not just a question. Yonggang Luo 11-Nov-2008 11:00 pm
.|..|# Re: This is not just a question. Simen Kjaeraas 11-Nov-2008 11:09 pm
.|..|# Re: This is not just a question. Kagamin 12-Nov-2008 03:26 am
.|..\# Re: This is not just a question. (Current message) Nick Sabalausky 12-Nov-2008 05:40 am
.\# Re: A question about the relation between different module. Jarrett Billingsley 11-Nov-2008 10:58 am