Pointer to interface method
BCS
ao at pathlink.com
Sun Apr 15 14:45:32 PDT 2007
Reply to Mandel,
> Hi,
>
> I like to have a pointer to an interface method,
> like this:
> interface Item
> {
> void work();
> }
> int main(char[][] args)
> {
> auto s = &Item.work
> return 0;
> }
> But this example fails because of an "undefined symbol" for Item.work.
> Is this a bug or intended behaviour?
>
An interface can't have static methouds so it needs to have an instance to
work on:
class CItem: Item
{
void work(){}
}
Item c = new CItem;
auto s = &c.work;
somthing like that should work. Note that the delegate you get will depend
on the class you use.
More information about the Digitalmars-d-learn
mailing list