static vs non-static
Zhenya
zheny at list.ru
Sun Jan 13 08:23:26 PST 2013
On Sunday, 13 January 2013 at 16:18:36 UTC, Maxim Fomin wrote:
> On Sunday, 13 January 2013 at 15:58:56 UTC, Zhenya wrote:
>> Hi!
>> Sorry,if it already was discussed,but
>>
>> import std.stdio;
>>
>> struct Foo
>> {
>> static void bar()
>> {
>> writeln("static");
>> }
>> void bar()
>> {
>> writeln("non-static");
>> }
>> }
>>
>> int main()
>> {
>> Foo gun;
>> gun.bar();//fails here
>> }
>>
>> Is it all right,that compiler dosn't prefer non-static
>> function in ths case?
>
> Main should be void in this case.
>
> Yes, it is a problem - dmd allows to call static functions on
> instance. When both match, it issues ambiguity error.
Hmmm...So it will remain as it is?
It hurts me a little bit(
More information about the Digitalmars-d-learn
mailing list