Is it possible to pass derived classes by reference to a function taking base class as a parameter

前端 未结 2 1997
执念已碎
执念已碎 2020-12-01 04:32

Say we have an abstract base class IBase with pure virtual methods (an interface).

Then we derive CFoo, CFoo2 from the base cl

2条回答
  •  天涯浪人
    2020-12-01 04:46

    You can cast an object just as you can a pointer. I remember this was common when converting char to unsigned char and various other sign changing casts in days of yore.

提交回复
热议问题