G
Guest
Hi,
I've been trying to figure this out for a while and can't find the answer.
For simplicity I will use a basic example rather than my real classes.
I have one base class, Item and various extended classes which inherit from
Item, ExtendedItem1, ExtendedItem2, etc. As expected, Item defines properties
and methods common to all items. The ExtendedItem classes define additional
properties and methods specific to different types of items.
At runtime, I create an instance of an Item. Depending on certain
conditions, I want to extend that Item into one of the ExtendedItem classes,
ie transform the Item object into an ExtendedItem1 or ExtendedItem2 object.
Is there an easy way to do this? Can I easily tell the ExtendedItem class to
use my already instanciated Item object as the base class? or do I have to
write a new constructor for each ExtendedItem class that accepts an Item
object and itializes all values in the base class to those in the Item object
parameter?
Any help is appreciated.
Thanks,
James
I've been trying to figure this out for a while and can't find the answer.
For simplicity I will use a basic example rather than my real classes.
I have one base class, Item and various extended classes which inherit from
Item, ExtendedItem1, ExtendedItem2, etc. As expected, Item defines properties
and methods common to all items. The ExtendedItem classes define additional
properties and methods specific to different types of items.
At runtime, I create an instance of an Item. Depending on certain
conditions, I want to extend that Item into one of the ExtendedItem classes,
ie transform the Item object into an ExtendedItem1 or ExtendedItem2 object.
Is there an easy way to do this? Can I easily tell the ExtendedItem class to
use my already instanciated Item object as the base class? or do I have to
write a new constructor for each ExtendedItem class that accepts an Item
object and itializes all values in the base class to those in the Item object
parameter?
Any help is appreciated.
Thanks,
James