B
bob
Hi,
we are using the composite pattern which simply has a common abstract
base class. Deriving from this class there is a Comp class, and a
CompItem class, say. i.e.
abstractBase
| \
| \
v \
Comp CompItem
|
|
V
CompItemSubClass
We have also the CompItemSubClass.
Now we can either have pointers to CompItems or CompItemSubClasses. I
want to be able to call the correct function (without dynamic casting
if possible).
e.g.
virtual void toto (CompItem* compItem);
virtual void toto (CompItemSubClass* compItemSubClass);
we have something like this;
CompItem* tmp=someFunc(); // creates either a CompItems
orCompItemSubClass
then I do;
toto(tmp);
which always invokes;
virtual void toto (CompItem* compItem);
Is there any nifty way to have
virtual void toto (CompItemSubClass* compItemSubClass);
called without casting (assuming the tmp contains a pointer to a
CompItemSubClass) ?
Thanks much. Hope that makes sense. I'm rushing here
grahamO
we are using the composite pattern which simply has a common abstract
base class. Deriving from this class there is a Comp class, and a
CompItem class, say. i.e.
abstractBase
| \
| \
v \
Comp CompItem
|
|
V
CompItemSubClass
We have also the CompItemSubClass.
Now we can either have pointers to CompItems or CompItemSubClasses. I
want to be able to call the correct function (without dynamic casting
if possible).
e.g.
virtual void toto (CompItem* compItem);
virtual void toto (CompItemSubClass* compItemSubClass);
we have something like this;
CompItem* tmp=someFunc(); // creates either a CompItems
orCompItemSubClass
then I do;
toto(tmp);
which always invokes;
virtual void toto (CompItem* compItem);
Is there any nifty way to have
virtual void toto (CompItemSubClass* compItemSubClass);
called without casting (assuming the tmp contains a pointer to a
CompItemSubClass) ?
Thanks much. Hope that makes sense. I'm rushing here
grahamO