Functions with package protection
Jacob Carlborg
doobnet at gmail.com
Fri Jun 20 09:00:52 PDT 2008
In the D documentation at http://www.digitalmars.com/d/1.0/function.html
it says the following: "All non-static non-private non-template member
functions are virtual", but this seems not to be the case. What I've
heard and as the following example shows functions declared as package
are non-virtual.
module main;
import tango.io.Stdout;
class A
{
package void foo ()
{
Stdout("A").newline;
}
}
class B : A
{
package void foo ()
{
Stdout("B").newline;
}
}
void main ()
{
A a = new B;
a.foo;
}
This will print "A", but according to the documentation package is
virtual and therefore this should print "B" but doesn't. Either the
documentation is wrong or the compiler.
Compiled with GDC on OSX, I think it will give the same result with dmd
also.
More information about the Digitalmars-d
mailing list