private method in interface
Michael Shulman
viritrilbia at gmail.com
Thu Jun 2 10:10:14 PDT 2011
Hi,
The following code fails the linker, complaining about an undefined
reference to 'foo':
interface A {
private int foo();
}
class B {
int bar(A x) { return x.foo(); }
}
void main() { }
But if I remove the 'private' qualifier on 'foo', then it succeeds.
Shouldn't B.bar() be able to access the private A.foo(), since they
are in the same package? If I move the definition of A into another
package, then the *compiler* fails with "interface member not
accessible", as I would expect.
Thanks!
Mike
More information about the Digitalmars-d-learn
mailing list