P
Peter Oliphant
Is there a way of defining a method in a base class such that derived
classes will call their own version, EVEN if the derived instance is
referred to by a pointer to the base class? Note that the base class method
is not to be abstract, and will be called if the instance was created as a
'generic' base class instance.
It's sort of like I want the method to be abstract to children, but concrete
at the base level. That way I can refer to an array of pointers to base
class elements that each will call its child's version of the method when
asked to execute this method (without being told (i.e., cast to) it's of
'child class' type).
Is this possible? I could create an abstract class that has this method as
abstract and derive both 'base class' and 'child class' from it, in which
case a pointer to the abstract class that holds an instance of the base or
child class will execute the approriate method. But then the 'child class'
is no longer a child of the 'base class'. I'd rather do it like I described
above...
Thanks in avance for responses! : )
[==P==]
classes will call their own version, EVEN if the derived instance is
referred to by a pointer to the base class? Note that the base class method
is not to be abstract, and will be called if the instance was created as a
'generic' base class instance.
It's sort of like I want the method to be abstract to children, but concrete
at the base level. That way I can refer to an array of pointers to base
class elements that each will call its child's version of the method when
asked to execute this method (without being told (i.e., cast to) it's of
'child class' type).
Is this possible? I could create an abstract class that has this method as
abstract and derive both 'base class' and 'child class' from it, in which
case a pointer to the abstract class that holds an instance of the base or
child class will execute the approriate method. But then the 'child class'
is no longer a child of the 'base class'. I'd rather do it like I described
above...
Thanks in avance for responses! : )
[==P==]