dynamic dispatch on operator arguments?

From: Mark P (not_at_my.real.email)
Date: 11/05/04


Date: Fri, 05 Nov 2004 12:12:39 -0800

Say I have a base class B and a derived class D.

Now I have some other class C in which I want to provide two functions:

void C::f(B* bObj);
void C::f(D* dObj);

The goal is that the version of f called should be determined by the
dynamic type of its argument. So if I had

C cObj;
B *pD = new D();
cObj.f(pD);

then cObj.f(pD) should call the second (D*) version of the function even
though the static type of pD is B*.

Is such a thing possible? If so, how?

Thanks,
Mark