Array of subclasses
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Oct 22 07:02:29 PDT 2015
On Thursday, 22 October 2015 at 06:14:34 UTC, DarkRiDDeR wrote:
> T[2] addons = [new A(), new B()];
Until pretty recently the compiler was a little picky about the
types here so you might have to explicitly cast the first element
to the base clas type.
T[2] addons = [cast(T) new A(), new B()];
casting just the first element tells it you want them all to be
interpreted as the base class.
I believe that is fixed in the newest version.
More information about the Digitalmars-d-learn
mailing list