digitalmars.D.bugs - BaseClass.member is not accessible
- "Vathix" <vathixSpamFix dprogramming.com> Jul 07 2004
- Russ Lewis <spamhole-2001-07-16 deming-os.org> Jul 08 2004
- "Vathix" <vathixSpamFix dprogramming.com> Jul 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.
Jul 07 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; } }
Jul 08 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.
Jul 08 2004








"Vathix" <vathixSpamFix dprogramming.com>