Interface "indexing"

Kagamin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Sep 6 11:11:43 PDT 2015


Well, you can have an array of event factories:

IEvent function()[2] factories = [ factory1, factory2 ];

IEvent factory1() { return new Event1(); }
IEvent factory2() { return new Event2(); }

Then use enum for indexing:
IEvent e = factories[NumEvent1]();


More information about the Digitalmars-d-learn mailing list