digitalmars.D.bugs - BaseClass.member is not accessible
- Vathix (16/16) Jul 07 2004 In test.d:
- Russ Lewis (10/32) Jul 08 2004 The compiler is griping (I think) because it thinks you're trying to
- Vathix (4/36) Jul 08 2004 I don't think so. This is a recently added feature. It lets you access o...
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: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.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