How to write own dynamic_cast

后端 未结 4 1506
失恋的感觉
失恋的感觉 2021-01-13 01:54

This have been asked in the interview.

How to write own dynamic_cast. I think, on the basis of typeid\'s name function.

Now how to implement own typid? I hav

4条回答
  •  佛祖请我去吃肉
    2021-01-13 02:14

    Easy. Derive all objects from some typeid interface with a virtual function WhoAmI(). Override it in all deriving classes.

提交回复
热议问题