D - another question about interfaces
- Ivan Senji (10/10) Apr 14 2004 why can't interfaces contain static functions?
- Russ Lewis (12/25) Apr 14 2004 My thought is that an interface defines an interface into a class.
- Ivan Senji (9/20) Apr 14 2004 OOps I am sorry this is what i wanted to write,
- Ivan Senji (4/15) Apr 15 2004 HM! I tried something like this in C# but it doesnt work there either.
why can't interfaces contain static functions? for example: interface IElement { static IElement create(){...} } I would expect that the class implementing this interface must define "static IElement create()" but if it doesn't the compiler doesn't complain and if it does implement this function I get a linker error?
Apr 14 2004
My thought is that an interface defines an interface into a class. Interfaces don't actually implement anything. So you would do something like this: interface IElement { static IElement create(); } class Foo : IElement { static IElement create() {...}; } Ivan Senji wrote:why can't interfaces contain static functions? for example: interface IElement { static IElement create(){...} } I would expect that the class implementing this interface must define "static IElement create()" but if it doesn't the compiler doesn't complain and if it does implement this function I get a linker error?
Apr 14 2004
"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message news:c5l2m7$t9j$1 digitaldaemon.com...My thought is that an interface defines an interface into a class. Interfaces don't actually implement anything. So you would do something like this: interface IElement { static IElement create(); } class Foo : IElement { static IElement create() {...}; }OOps I am sorry this is what i wanted to write, the {}in the interface are a typing error. The actual code looks just like the one you wrote but it doesnt work. If class Foo does implement IElement but it doesn't implement "static IElement create()" this isn't an error but even if it does implement it i get a linker error.
Apr 14 2004
"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message news:c5l2m7$t9j$1 digitaldaemon.com...My thought is that an interface defines an interface into a class. Interfaces don't actually implement anything. So you would do something like this: interface IElement { static IElement create(); } class Foo : IElement { static IElement create() {...}; }But it would be very useful in D :)
Apr 15 2004