Hi,
Class B inherits from class A
class D inherits from class A
D has a function say, fun_D()
B has a function say, fun_B(A* Dtype)
I want to call fun_D() from B. But I don't want to include fun_D in A.Code:void main() { D *pD = new D(); B *pB = new B(); pB->fun_B(pD); }
The best way I could think was,
But I am not happy with this casting. Is there any better way to do this?Code:void B::fun_B(A *Dtype) { D *lDtype = static_cast <D*>(Dtype); lDtype->fun_D(); }
Best Regards,
Shal