This is not just a question.

Yonggang Luo yonggangluo at hotmail.com
Tue Nov 11 20:00:28 PST 2008


Jarrett Billingsley Wrote:

> On Tue, Nov 11, 2008 at 10:56 AM, Yonggang Luo <yonggangluo at hotmail.com> wrote:
> > And the other file that named
> > subClass.d
> > The content is
> > module subClass;
> > private import baseClass; /*!!!!!!!! Please notice, this is private import*/
> 
> "private import" only means that if another module, say "main,"
> imports subClass, it won't see baseClass unless it does "import
> baseClass;".  It does not change what you can access out of baseClass.
> 
> > class Sub:Base /*Is this legal?*/
> > {
> > };
> 
> Once again, yes.
This is not just a question. 
I think this must be illegal..
Why? 
Because we are "private import baseClass;"

and Now we create the third file that named thirdClass.d;
The content is.

module thirdClass;
private import subClass;

so if  class Sub:Base is legal, then we also can access Base.
But the  fact is "private import Base";
from this clue , we can't access Base Class.
So it's confusing.


> 
> > void DoSomeThins()
> > {
> >        Function(); /*Is this legal?*/
> > }
> 
> Yes, again.
> 
> > private void DoPrivateFunctions(Base x) /*Is this legal?*/
> > {
> > }
> 
> Of course.
> 
> > public void DoPublicFunctions(Base x) /*Is this legal?*/
> > {
> > }
> 
> Yes.
/*Also is here */

> 
> > private alias Base BaseAlternative; /*Is this legal?*/
> 
> Yes!
> 
> > public alias Base PublicBase; /*Is this legal?*/
> 
> Yes!
/*/*Also is here */
> 
> As ore-sama said, please try compiling these things before asking.
> 
> Also, please put learning questions on digitalmars.D.learn, not on
> digitalmars.D.




More information about the Digitalmars-d mailing list