Is it possible to store different subclasses in one array?
Leonardo
leotada523 at gmail.com
Mon Apr 13 01:42:51 UTC 2020
Is it possible to store different subclasses in one array?
In C#, we have this example, but how I do that in D?
public class BaseItem{
public string name = "";
}
public class Weapon : BaseItem{
public int damage = 10;
}
public class Potion : BaseItem{
public int hpRestore = 50;
}
var GameItems = new List<BaseItem>();
GameItems.Add(new Weapon());
GameItems.Add(new Potion());
More information about the Digitalmars-d-learn
mailing list