I use a library that generates a bunch of classes for me.
These classes all inherit from a common base class, but this base class does not define pairs of methods that are common to all subclasses.
For example:
SubClassA : BaseClass{
void Add(ItemA item) {...}
ItemA CreateNewItem() {...}
}
SubClassB: BaseClass{
void Add(ItemB item) {...}
ItemB CreateNewItem() {...}
}
Unfortunately, the base class does not have these methods . It would be great:
BaseClass{
abstract void Add(ItemBaseClass item);
abstract ItemBaseClass CreateNewItem();
}
Since there is a common base class for my A + B objects and a common base class for Item objects, I was hoping to capitalize on the wonderful world of polymorphism.
Unfortunately, since ordinary methods are not actually present in the base class, I cannot actually name them. for example, this would be ideal:
BaseClass Obj;
Obj = GetWorkUnit();
ItemBaseClass Item = Obj.CreateNewItem();
Item.DoSomething();
Obj.Add(Item);
Obviously casting will work, but then I will need to know what type I had that would deny the benefits.
"" ? , , . , VB - intellisense, , :
CType(Obj, Object).Add(Item)
Againt, (, , ).