This is not just a question.
Nick Sabalausky
a at a.a
Wed Nov 12 02:40:21 PST 2008
"Yonggang Luo" <yonggangluo at hotmail.com> wrote in message
news:gfdkcs$1all$1 at 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".
More information about the Digitalmars-d
mailing list