Thread overview
BaseClass.member is not accessible
Jul 08, 2004
Vathix
Jul 08, 2004
Russ Lewis
Jul 09, 2004
Vathix
July 08, 2004
In test.d:

class Foo
{
   protected int bar;
}


In main.d:

import test;
class Bar: Foo
{
   this()
   {
      //Foo.bar = 2; // class Foo member bar is not accessible
      bar = 2; // Works
   }
}


The commented assignment should work but doesn't.


July 08, 2004
Vathix wrote:
> In test.d:
> 
> class Foo
> {
>    protected int bar;
> }
> 
> 
> In main.d:
> 
> import test;
> class Bar: Foo
> {
>    this()
>    {
>       //Foo.bar = 2; // class Foo member bar is not accessible
>       bar = 2; // Works
>    }
> }
> 
> 
> The commented assignment should work but doesn't.

The compiler is griping (I think) because it thinks you're trying to assign to a static member of Foo.  You can do this:

class Bar: Foo
{
  this()
  {
    super.bar = 2;
  }
}

July 09, 2004
"Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:cckioe$3od$1@digitaldaemon.com...
> Vathix wrote:
> > In test.d:
> >
> > class Foo
> > {
> >    protected int bar;
> > }
> >
> >
> > In main.d:
> >
> > import test;
> > class Bar: Foo
> > {
> >    this()
> >    {
> >       //Foo.bar = 2; // class Foo member bar is not accessible
> >       bar = 2; // Works
> >    }
> > }
> >
> >
> > The commented assignment should work but doesn't.
>
> The compiler is griping (I think) because it thinks you're trying to assign to a static member of Foo.  You can do this:
>
> class Bar: Foo
> {
>    this()
>    {
>      super.bar = 2;
>    }
> }
>

I don't think so. This is a recently added feature. It lets you access one of the base's [instance] members since super can't work past one level.