Overloading of static and instance members
Michal Minich
michal.minich at gmail.com
Fri Dec 11 06:38:30 PST 2009
Consider this example:
struct A
{
static void foo () {}
void foo () {}
}
void main ()
{
A a;
A.foo(); // error here
a.foo(); // and same here
}
Error: function main.A.foo called with argument types:
(())
matches both:
main.A.foo()
and:
main.A.foo()
Which is ok for "a.foo()" case, because it is possible to call static and
instance functions on instance variable. But I would expect to be possible
to call A.foo() because there is no ambiguity.
Can somebody please explain me rationale behind this. Can this possibly prevent
some errors? Because now it seems to me like unnecessary restriction.
If this has reason, why then not issue error sooner - when declaring static/instance
overloaded functions.
More information about the Digitalmars-d-learn
mailing list